-- 作者: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 '2<5' An example of a frequent use of entity references is when a Java program is represented as an XML document
|