以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XML基础 』  (http://bbs.xml.org.cn/list.asp?boardid=1)
----  XML 中的entity reference 和 DTD中的entuty reference 不是一回事?  (http://bbs.xml.org.cn/dispbbs.asp?boardid=1&rootid=&id=83865)


--  作者:iwsyang
--  发布时间:3/17/2010 6:03:00 AM

--  XML 中的entity reference 和 DTD中的entuty reference 不是一回事?
哪位好心人帮我理解一下:

DTD:

Pieces of an XML document may be stored on different storage units
Entities are storage units, which contain pieces of an XML document
Entity references are used to load these entities into main XML document
There are two kinds of entity references:
Parameter entity references that load data into the document’s DTD, and
General entity references that load data into the root element

XML
Entity references are markup that is replaced with character data when the document is parsed
A browser parses an XML document before it renders it
Wherever an entity reference appears in an XML document, it is textually replaced by its content
Entity references are used in XML documents in place of specific characters (like: <, “,…) that would otherwise be interpreted as part of markup
Example:
An entity reference has to be used to replace the sign “<” in the expression “x < 5”, otherwise “<” would be interpreted as a start of a markup

Entity references start with a ‘&’ and end with a ‘;’
There are five predefined entities:
< is represented by lt,
& is represented by amp,
> is represented by gt,
“ is represented by quot, and
‘ is represented by apos
‘2 < 5’ is encoded as &apos;2&lt;5&apos;
An example of a frequent use of entity references is when a Java program is represented as an XML document


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
46.875ms