??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲国产一区二区三区在线播,成人av动漫,成人a视频在线http://www.aygfsteel.com/yuxh/category/48139.htmlwayzh-cnThu, 24 Mar 2011 02:01:13 GMTThu, 24 Mar 2011 02:01:13 GMT60XML介绍http://www.aygfsteel.com/yuxh/archive/2011/03/24/346908.htmlyuxhyuxhThu, 24 Mar 2011 01:05:00 GMThttp://www.aygfsteel.com/yuxh/archive/2011/03/24/346908.htmlhttp://www.aygfsteel.com/yuxh/comments/346908.htmlhttp://www.aygfsteel.com/yuxh/archive/2011/03/24/346908.html#Feedback0http://www.aygfsteel.com/yuxh/comments/commentRss/346908.htmlhttp://www.aygfsteel.com/yuxh/services/trackbacks/346908.htmlDTDs

Introduced as part of the XML 1.0 specification, DTDs are the oldest constraint model around in the XML world. They're simply to use, but this simplicity comes at a price: DTDs are inflexible, and offer you little for data type validation as well.

XML Schema (XSD)

XML Schema is the W3C's anointed successor to DTDs. XML Schemas are literally orders of magnitude more flexible than DTDs, and offer an almost dizzying array of support for various data types. However, just as DTDs were simple and limited, XML Schemas are flexible, complex, and (some would argue) bloated. It takes a lot of work to write a good schema, even for 50- or 100-line XML documents. For this reason, there's been a lot of dissatisfaction with XML Schema, even though they are widely being used.

[prefix]:[element name]
元素Q?br>root元素必须包含所有文档中的元素,只能有一个root元素。元素名只能以下划线或字母开_不能有空|区分大小写。开元素必须有对应闭元素Q也有类似html的简写,?lt;img src="http://www.aygfsteel.com/images/xml.gif" />Q。文由DTD或schema来限制它是否合格?/pre>
属性:
什么时候用属性?基本原则Q多个值的数据用元素,单值的数据用元素。如果数据有很多值或者比较长Q数据最可能属于元素。他主要被当作文本,?lt;rss:author>Doug Hally</rss:author> <journal:author>Neil Gaiman</journal:author>易搜索,好用。比如一本书的章节描q。然而如果数据主要作为单值处理的话,最好作为属性。如果搞不清楚,可以安全的用元素?/pre>
命名I间NamespacesQ?br>xml的命名空间是一U用一个特定的URI来关联XML文里的一个或多个元素的方法。意味着元素是由名字和命名空间一h识别的。许多复杂的XML文g里,同一个名字会有多个用途。比如,一个RSS feed有一个作者,q个作者同时是每个日记的。虽然这些数据都用author元素来表C,但他们不应该被当作同一?em>cd的数据。命名空间很好的解决了这个问题,命名I间说明书要求一个前~和唯一的URI联合h区分不同命名I间里的元素。如http://www.neilgaiman.com/entries作ؓURIQ联合前~journal用来表示日志相关的元素?br><rdf:RDF xmlns:rss="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:journal="http://www.neilgaiman.com/entries">Q然后就可用了Q?br><rss:author>Doug Hally</rss:author> <journal:author>Neil Gaiman</journal:author>实际上在使用命名I间前缀的时候再定义也可以的Q?br><rss:author xmlns:rss="http://www.w3.org/1999/02/22-rdf-syntax-ns#">Doug Hally</rss:author>
如果名字没有命名I间Q不代表在默认命名空间中Q而是xml处理器以在Q何命名空间以外方式解释他。要声明默认命名I间的话׃用后面冒号部分,?lt;Insured xmlns="使用的一些术?/strong>:
  • The name of a namespace (such as http://www.ibm.com/software) is the namespace URI.

  • The element or attribute name can include a prefix and a colon (as in prod:Quantity). A name in that form is called a qualified name, or QName, and the identifier that follows the colon is called a local name. If a prefix is not in use, neither is the colon, and the QName and local name are identical.

  • An XML identifier (such as a local name) that has no colon is sometimes called an NCName. (The NC comes from the phrase no colon.)

Entity references:
用来处理转义字符Q语法是& [entity name] ;XML解析器碰到这Uentity referenceQ就会用对应的值替换掉他。如&lt;Q?lt;Q?&gt;(>),&amp;(&),&quot;("),&apos;(')。注意entity reference是用户可定义的。比如多处用到版权提C,自己定义后以后更改就方便了:<ora:copyright>&OReillyCopyright;</ora:copyright>。除了用来表C数据中的复杂或Ҏ字符外,entity referenceq会有更多用途?/p>

不解析的数据Q?br>当传输大量数据给应用且不用xml解析的时候,CDATA有用了。当大量的字W需要用entity reference转义的时候,或空格必M留的时候,使用CDATA?lt;![CDATA[?]]>



yuxh 2011-03-24 09:05 发表评论
]]> վ֩ģ壺 Ӽ| Ȫ| | | ʡ| | | Դ| ̩| ˫| ʡ| | | Ȩ| | | | ˳| | ά| | | | | Ӳ| ۰| | | Դ| ƺ| ˹| ½| | | | ʯɽ| ɽ| ÷ӿ| ɽ| | Ž|