Difference between PCDATA and CDATA

王朝other·作者佚名  2006-01-10
窄屏简体版  字體: |||超大  

> #PCDATA [...] specifies that an element will contain parsed

> character data. Parsing tests whether the characters conform to the

> lexical constraints imposed by XML 1.0.

>

> CDATA appears in attribute declarations and specifies that an

> attribute will contain character data that is not parsed.

That's not accurate. All characters in an XML document are "parsed" in

the sense that you describe.

"CDATA" is a token used in an attribute declaration to declare the

attribute as having a string type. '&', and '<' and the quote character

used for delimiting the attribute value have special meaning in

attributes of this type.

"#PCDATA" is a token used in an element declaration to declare the

element as having mixed content (character data, or character data mixed

with other elements). The content of the element is parsed; '&' and '<'

have special meaning and must be escaped if they aren't the start of

markup.

A "CDATA section", bounded in markup by "<![CDATA[" and "]]>" is, by

comparison, "unparsed" character data (though even it is subject to at

least one restriction -- it can't contain "]]>"). A CDATA section can

only appear in element content, and it has nothing to do with the

"CDATA" token used in attribute decls.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航