Extensible Markup Language (XML) 1.0

±¾ÎĵµÊÇW3C½¨ÒéXML 1.0(1998Äê2ÔÂ10ÈÕ)µÄÖÐÎİ棬ÆäÖпÉÄÜÓдíÎóºÍ²»Í×Ö®´¦¡£

Ó¢ÎÄ°æÊÇΨһµÄÕýʽ°æ£¬Î»ÓÚ£º

http://www.w3.org/TR/1998/REC-xml-19980210

±¾ÎĵµÎ»ÓÚ£º

http://lightning.prohosting.com/~qqiu/xml/trans/REC-xml-19980210-cn.html

ÒëÕߣº

Öø×÷ȨÉùÃ÷λÓÚ£ºhttp://www.w3.org/Consortium/Legal/copyright-documents.html

Copyright  ©  1998 W3C (MIT£¬ INRIA£¬ Keio )£¬ All Rights Reserved. W3C liability£¬ trademark£¬ document use and software licensing rules apply.

W3CREC-xml-19980210-cn


¿ÉÀ©Õ¹±ê¼ÇÓïÑÔ(XML) 1.0

W3C½¨Òé 1998Äê2ÔÂ10ÈÕ

±¾°æ±¾:
http://www.w3.org/TR/1998/REC-xml-19980210
http://www.w3.org/TR/1998/REC-xml-19980210.xml
http://www.w3.org/TR/1998/REC-xml-19980210.html
http://www.w3.org/TR/1998/REC-xml-19980210.pdf
http://www.w3.org/TR/1998/REC-xml-19980210.ps
×îа汾:
http://www.w3.org/TR/REC-xml
ÉÏÒ»°æ±¾:
http://www.w3.org/TR/PR-xml-971208
±àÕß:
Tim Bray (Textuality and Netscape) <tbray@textuality.com>
Jean Paoli (Microsoft) <jeanpa@microsoft.com>
C. M. Sperberg-McQueen (University of Illinois at Chicago) <cmsmcq@uic.edu>

ÕªÒª

±¾ÎĵµÍêÕûµØÃèÊöÁË¿ÉÀ©Õ¹±ê¼ÇÓïÑÔ(Extensible Markup Language£¬XML)£¬ËüÊDZê׼ͨÓñê¼ÇÓïÑÔ(Standard Generic Markup Language£¬SGML)µÄÒ»¸ö×Ó¼¯¡£ÆäÄ¿µÄÔÚÓÚʹµÃÔÚWebÉÏÄÜÒÔÏÖÓг¬Îı¾±ê¼ÇÓïÑÔ(Hypertext Markup Language£¬HTML)µÄʹÓ÷½Ê½Ìṩ£¬½ÓÊպʹ¦ÀíͨÓõÄSGML³ÉΪ¿ÉÄÜ¡£XMLµÄÉè¼Æ¼È¿¼ÂÇÁËʵÏֵķ½±ãÐÔ£¬Í¬Ê±Ò²¹Ë¼°ÁËÓëSGMLºÍHTMLµÄ»¥²Ù×÷ÐÔ¡£

±¾ÎĵµµÄ״̬

±¾ÎĵµÒÑÓÉW3C×éÖ¯³ÉÔ±ºÍÆäËûÏà¹Ø¸÷·½ÉóÔÄ£¬²¢Òѱ»×éÖ¯ÀíÊÂÅú׼ΪW3C½¨Òé¡£ÕâÊÇÒ»¸öÎȶ¨µÄÎĵµ£¬¿ÉÒÔÓÃ×÷²Î¿¼²ÄÁÏ£¬Ò²¿ÉÒÔ×÷ΪÆäËûÎĵµµÄÕýʽ²Î¿¼ÎÄÏס£W3CÔÚ½¨ÒéÖƶ¨¹ý³ÌÖеÄ×÷ÓÃÊÇÎüÒý¶Ô±¾¹æ·¶µÄ×¢Òâ²¢´Ù½øËüµÄ¹ã·ºÊ¹Óá£ÕâÄÜÔöÇ¿WebµÄ¹¦Äܺͻ¥²Ù×÷ÐÔ¡£

±¾Îĵµ¹æ¶¨ÁËÒ»ÖÖÓÃÓÚWorld Wide WebµÄÓï·¨£¬´ËÓï·¨ÊÇͨ¹ýÈ¡Ò»¸öÒµÒÑ´æÔÚ²¢Òѹ㷺ʹÓõÄÎı¾´¦Àí¹ú¼Ê±ê×¼(±ê׼ͨÓñê¼ÇÓïÑÔ£¬¾­Ôö²¹ºÍ¸üÕýµÄISO 8879:1986(E))µÄ×Ó¼¯¶ø´´½¨µÄ¡£ËüÊÇW3C XMLÐж¯×é(XML Activity)µÄ¹¤×÷³É¹û£¬¹ØÓÚXMLÐж¯×éµÄÏêϸÐÅÏ¢¿ÉÒÔÔÚhttp://www.w3.org/XMLÕÒµ½¡£ÔÚhttp://www.w3.org/TR¿ÉÒÔÕÒµ½ÏÖÓÐW3C½¨ÒéºÍÆäËû¼¼ÊõÎĵµµÄÒ»¸öÁÐ±í¡£

±¾¹æ·¶ÖÐʹÓÃÁË[Berners-LeeµÈÈË]¶¨ÒåµÄÒ»¸öÊõÓïURI£¬ËûÃÇÕýÔÚ´ÓʵĵŤ×÷½«¸üÐÂ[IETF RFC1738]ºÍ[IETF RFC1808]¡£

±¾¹æ·¶µÄÒÑÖª´íÎóÁбí¿ÉÒÔÔÚhttp://www.w3.org/XML/xml-19980210-errataÕÒµ½¡£

Ç뽫±¾ÎĵµÖеĴíÎ󱨸æ¸øxml-editor@w3.org¡£

¿ÉÀ©Õ¹±ê¼ÇÓïÑÔ(XML) 1.0

Ŀ¼

1. Ð÷ÂÛ
    1.1 ¿ª·¢ÕߺͿª·¢Ä¿±ê
    1.2 ÊõÓï
2. Îļþ
    2.1 ¹æ·¶µÄXMLÎļþ
    2.2 ×Ö·û
    2.3 ͨÓÃÓï·¨³É·Ö
    2.4 ×Ö·ûÊý¾ÝºÍ±ê¼Ç
    2.5 ×¢ÊÍ
    2.6 ´¦ÀíÖ¸Áî
    2.7 CDATA¶Î
    2.8 ÐòºÍÎļþÀàÐÍÉùÃ÷
    2.9 ¶ÀÁ¢ÎļþÉùÃ÷
    2.10 ¿Õ°×´¦Àí
    2.11 ÐÐβ´¦Àí
    2.12 ÓïÑÔ±êʶ
3. Âß¼­½á¹¹
    3.1 Æðʼ±êÇ©£¬½áÊø±êÇ©ºÍ¿ÕÔªËرêÇ©
    3.2 ÔªËØÀàÐÍÉùÃ÷
        3.2.1 ÔªËØÐÍÄÚÈÝ
        3.2.2 »ìºÏÐÍÄÚÈÝ
    3.3 ÊôÐÔ±íÉùÃ÷
        3.3.1 ÊôÐÔÀàÐÍ
        3.3.2 ÊôÐÔµÄȱʡֵ
        3.3.3 ÊôÐÔ-Öµ¶ÔµÄ¹æ·¶»¯
    3.4 Ìõ¼þ¶Î
4. ÎïÀí½á¹¹
    4.1 ×Ö·ûºÍʵÌåÒýÓÃ
    4.2 ʵÌåÉùÃ÷
        4.2.1 ÄÚ²¿ÊµÌå
        4.2.2 ÍⲿʵÌå
    4.3 ÒÑÎöʵÌå
        4.3.1 Îı¾ÉùÃ÷
        4.3.2 ¹æ·¶µÄÒÑÎöʵÌå
        4.3.3 ʵÌåÖеÄ×Ö·û±àÂë
    4.4 XML´¦ÀíÆ÷¶ÔʵÌåºÍÒýÓõĴ¦Àí
        4.4.1 ²»±»Ê¶±ð
        4.4.2 ±»°üº¬
        4.4.3 ½øÐÐÑé֤ʱ±»°üº¬
        4.4.4 ±»½ûÖ¹
        4.4.5 ±»°üº¬ÔÚ³£Á¿ÖÐ
        4.4.6 ֪ͨ
        4.4.7 ²»´¦Àí
        4.4.8 ×÷ΪPE±»°üº¬
    4.5 ÄÚ²¿ÊµÌåÖû»Îı¾µÄ¹¹½¨
    4.6 Ô¤¶¨ÒåʵÌå
    4.7 ¼Ç·¨ÉùÃ÷
    4.8 ÎļþʵÌå
5. Ò»ÖÂÐÔ
    5.1 ½øÐÐÑéÖ¤ºÍ²»½øÐÐÑéÖ¤µÄ´¦ÀíÆ÷
    5.2 ʹÓÃXML´¦ÀíÆ÷
6. ¼Ç·¨

¸½Â¼

A. ²Î¿¼ÎÄÏ×
    A.1 Õýʽ²Î¿¼ÎÄÏ×
    A.2 ÆäËû²Î¿¼ÎÄÏ×
B. ×Ö·ûµÄ·ÖÀà
C. XMLºÍSGML(·ÇÕýʽ)
D. ʵÌåºÍ×Ö·ûÒýÓõÄÕ¹¿ª(·ÇÕýʽ)
E. È·¶¨ÐÍÄÚÈÝÄ£ÐÍ(·ÇÕýʽ)
F. ×Ö·û±àÂëµÄ×Ô¶¯¼ì²â(·ÇÕýʽ)
G. W3C XML¹¤×÷×é(·ÇÕýʽ)


1. Ð÷ÂÛ

¿ÉÀ©Õ¹±ê¼ÇÓïÑÔ£¬ËõдΪXML£¬ÃèÊöÁËÒ»Àà³ÆΪXMLÎļþµÄÊý¾Ý¶ÔÏó£¬Í¬Ê±Ò²²¿·ÖµØÃèÊöÁË´¦ÀíÕâЩÊý¾Ý¶ÔÏóµÄ¼ÆËã»ú³ÌÐòµÄ¶¯×÷¡£XMLÊÇSGML(±ê׼ͨÓñê¼ÇÓïÑÔ[ISO 8879])Õë¶ÔÌض¨Ó¦ÓÃÁìÓòµÄÒ»¸ö×Ó¼¯£¬»òÕß˵ÊÇSGMLµÄÒ»ÖÖÊÜÏÞÐÎʽ¡£¸ù¾Ý¶¨Ò壬XMLÎļþÊǺϺõ¹æ·¶µÄSGMLÎļþ¡£

XMLÎļþÓɳÆΪʵÌåµÄ´æ´¢µ¥Ôª×é³É£¬ÊµÌå¿ÉÒÔ°üº¬ÒÑÎöÊý¾Ý»òδÎöÊý¾Ý¡£ÒÑÎöÊý¾ÝÓÉ×Ö·û×é³É£¬ÆäÖÐһЩ×Ö·û×é³É×Ö·ûÊý¾Ý£¬ÁíһЩ×Ö·û×é³É±ê¼Ç¡£±ê¼ÇÖаüº¬Á˶ÔÎļþ´æ´¢¸ñʽ(storage layout)ºÍÂß¼­½á¹¹µÄÃèÊö¡£XMLÌṩÁËÒ»ÖÖ»úÖÆÓÃÓÚÔ¼Êø´æ´¢¸ñʽºÍÂß¼­½á¹¹¡£

³ÆΪXML´¦ÀíÆ÷µÄÈí¼þÄ£¿éÓÃÓÚ¶ÁÈ¡XMLÎļþ£¬´æÈ¡ÆäÖеÄÄÚÈݺͽṹ¡£XML´¦ÀíÆ÷±»ÉèÏëΪÊÇΪÁíÒ»¸ö³ÆΪӦÓõÄÄ£¿é×÷´¦Àí¡£±¾¹æ·¶´ÓXML´¦ÀíÆ÷Ó¦ÈçºÎ¶ÁÈ¡XMLÊý¾ÝÒÔ¼°Ó¦ÏòÓ¦ÓÃÌṩÄÄЩÐÅÏ¢µÄÕâÁ½¸ö·½Ã棬ÃèÊöÁËÒªÇóXML´¦ÀíÆ÷×÷³öµÄ¶¯×÷¡£

1.1 ¿ª·¢ÕߺͿª·¢Ä¿±ê

XMLÓÉXML¹¤×÷×é(Ô­ÏȵÄSGML±à¼­Éó²éίԱ»á)¿ª·¢£¬´Ë¹¤×÷×éÓÉWorld Wide Web Consortium(W3C)ÔÚ1996ÄêÖ÷³Ö³ÉÁ¢¡£¹¤×÷×éÓÉSun MicrosystemsµÄJon Bosak¸ºÔð£¬Í¬ÑùÓÉW3C×éÖ¯µÄXML SIG(Special Interest Group)(Ô­ÏȵÄSGML¹¤×÷×é)»ý¼«²ÎÓëÁËXML¹¤×÷×éµÄ¹¤×÷¡£XML¹¤×÷×éµÄ³ÉÔ±ÔÚ¸½Â¼Öиø³ö¡£ ¹¤×÷×éÓëW3CµÄÁªÏµÈËÊÇDan Connolly¡£

XMLµÄÉè¼ÆÄ¿±êÈçÏ£º

  1. XMLÓ¦¸Ã¿ÉÒÔÖ±½ÓÓÃÓÚÒòÌØÍø(Internet)¡£
  2. XMLÓ¦¸ÃÖ§³Ö´óÁ¿²»Í¬µÄÓ¦Óá£
  3. XMLÓ¦¸ÃÓëSGML¼æÈÝ¡£
  4. ´¦ÀíXMLÎļþµÄ³ÌÐòÓ¦¸ÃÈÝÒ×±àд¡£
  5. XMLÖеĿÉÑ¡ÏîÓ¦ÎÞÌõ¼þµØ±£³Ö×îÉÙ£¬ÀíÏë×´¿öÏÂÓ¦¸ÃΪ0¸ö¡£
  6. XMLÎļþÓ¦¸ÃÊÇÈË¿ÉÒÔÖ±½ÓÔĶÁµÄ£¬Ó¦¸ÃÊÇÌõÀíÇå³þµÄ¡£
  7. XMLµÄÉè¼ÆÓ¦¿ìËÙÍê³É¡£
  8. XMLµÄÉè¼ÆÓ¦¸ÃÊÇÐÎʽ»¯µÄ£¬¼ò½àµÄ¡£
  9. XMLÎļþÓ¦Ò×ÓÚ´´½¨¡£
  10. XML±ê¼ÇµÄ¼ò½àÐÔÊÇ×îºó¿¼ÂǵÄÄ¿±ê¡£

±¾¹æ·¶ÓëÆäËûÏà¹ØµÄ±ê×¼Ò»Æð(UnicodeºÍISO/IEC 10646¶¨ÒåÁË×Ö·û¼¯£¬Internet RFC1766¶¨ÒåÁËÓïÑÔʶ±ðÂ룬ISO 639¶¨ÒåÁËÓïÑÔÃû³Æ´úÂ룬ISO 3166¶¨ÒåÁ˹ú¼ÒÃû³Æ´úÂë)£¬ÌṩÁËÀí½âXML°æ±¾1.0ºÍ¹¹½¨ÏàÓ¦¼ÆËã»ú´¦Àí³ÌÐòËùÐèµÄËùÓÐÐÅÏ¢¡£

ÔÚÍêÕû±£ÁôËùÓÐÎı¾ºÍ·¨ÂÉ×¢ÒâÊÂÏîµÄÇ°ÌáÏ£¬±¾°æ±¾µÄXML¹æ·¶¿ÉÒÔ×ÔÓÉ·Ö·¢¡£

1.2 ÊõÓï

ÓÃÓÚÃèÊö XML ÎļþµÄÊõÓïÔڴ˹淶µÄÕýÎÄÖж¨Òå¡£ ÔÚÕâЩ¶¨ÒåÖÐÒÔ¼°ÃèÊöÒ»¸öXML´¦ÀíÆ÷µÄ¶¯×÷ʱ£¬Ê¹ÓÃÁËϱíÖеÄÊõÓ

¿ÉÒÔ(may)
ÔÊÐíºÏºõ¹æ·¶µÄÎļþºÍXML´¦ÀíÆ÷°´ËùÃèÊöµÄ·½Ê½¹¤×÷£¬µ«²»ÒªÇó±ØÐëÈç´Ë¡£
±ØÐë(must)
ÒªÇóºÏºõ¹æ·¶µÄÎļþºÍXML´¦ÀíÆ÷°´ËùÃèÊöµÄ·½Ê½¹¤×÷; ·ñÔòËüÃdzöÏÖ´íÎó¡£
´íÎó(error)
¶Ô±¾¹æ·¶ÖеĹæÔòµÄÎ¥·´; Æä½á¹û²»È·¶¨¡£ºÏºõ¹æ·¶µÄÈí¼þ¿ÉÒÔ¼ì²âºÍ±¨¸æ´íÎ󣬲¢¿ÉÒÔ´ÓÖлָ´¡£
ÑÏÖØ´íÎó(fatal error)
ºÏºõ¹æ·¶µÄXML´¦ÀíÆ÷±ØÐë¼ì²âµ½£¬²¢ÏòÓ¦Óñ¨¸æµÄÒ»Àà´íÎó¡£ÔÚÓöµ½ÑÏÖØ´íÎóÖ®ºó£¬´¦ÀíÆ÷¿ÉÒÔ¼ÌÐø´¦ÀíÊý¾ÝÒÔ·¢ÏÖ¸ü¶àµÄ´íÎ󲢿ÉÒÔÏòÓ¦Óñ¨¸æÕâЩ´íÎó¡£ÎªÁËÖ§³Ö´íÎóµÄ¸üÕý£¬´¦ÀíÆ÷¿ÉÒÔÏòÓ¦ÓÃÌṩÎļþÖÐδ¾­´¦ÀíµÄÊý¾Ý(×Ö·ûÊý¾ÝºÍ±ê¼ÇµÄ»ìºÏÌå)¡£µ«ÊÇ£¬Ò»µ©¼ì²âµ½Ò»¸öÑÏÖØ´íÎ󣬴¦ÀíÆ÷±ØÐëÍ£Ö¹Õý³£µÄ´¦Àí(Ò²¾ÍÊÇ˵£¬Ëü±ØÐëÍ£Ö¹ÒÔÕý³£µÄ·½Ê½ÏòÓ¦ÓÃÌṩÓëÎļþÂß¼­½á¹¹ÓйصÄÊý¾ÝºÍÐÅÏ¢)¡£
ÓÉÓû§Ñ¡Ôñ(at user option)
ºÏºõ¹æ·¶µÄÈí¼þ¿ÉÒÔ»òÕß±ØÐë(È¡¾öÓÚ¾ä×ÓÖеÄÇé̬¶¯´Ê)°´ËùÃèÊöµÄ·½Ê½¹¤×÷; Èç¹ûËüÂú×ãÕâ¸öÌõ¼þ£¬Ëü±ØÐëͬʱÌṩÓû§Ò»ÖÖÊֶΣ¬Ê¹µÃÓû§Äܹ»ÆôÓúͽûÓÃËùÃèÊöµÄ¹¤×÷·½Ê½¡£
ÓÐЧÐÔÔ¼Êø(validity constraint)
ÊÊÓÃÓÚËùÓÐÓÐЧµÄXMLÎļþµÄÒ»ÖÖ¹æÔò¡£Î¥·´ÓÐЧÐÔÔ¼ÊøÊôÓÚ´íÎó;½øÐÐÑéÖ¤µÄXML´¦ÀíÆ÷±ØÐ룬ÓÉÓû§Ñ¡Ôñ£¬±¨¸æÕâЩ´íÎó¡£
¹æ·¶ÐÔÔ¼Êø(well-formedness constraint)
ÊÊÓÃÓÚËùÓй淶µÄXMLÎļþµÄÒ»ÖÖ¹æÔò¡£Î¥·´¹æ·¶ÐÔÔ¼ÊøÊôÓÚÑÏÖØ´íÎó¡£
Æ¥Åä(match)
(¶ÔÓÚ×Ö·û´®ºÍÃû×Ö£º)±»±È½ÏµÄÁ½¸ö×Ö·û´®»òÃû×Ö±ØÐëÍêÈ«Ïàͬ¡£ÔÚISO/IEC 10646ÖÐÓжàÖÖ¿ÉÄܱíʾ·½Ê½µÄ×Ö·û(ÀýÈ磬¼ÈÓÐÔ¤¶¨Òå(precomposed)ÐÎʽºÍ»ù×Ö·û(base)+±äÒô·ûÐÎʽµÄ×Ö·û)Ö»ÔÚÁ½¸ö×Ö·û´®Öеıíʾ·½Ê½Ïàͬʱ²ÅÆ¥Åä¡£ÓÉÓû§Ñ¡Ôñ£¬´¦ÀíÆ÷¿ÉÒÔ½«ÕâЩ×Ö·û¹æ·¶³ÉijÖֹ淶ÐÎʽ¡£²»½øÐÐ×Ö·ûµÄ´óСдת»»¡£(¶ÔÓÚÎÄ·¨ÖеÄ×Ö·û´®ºÍ¹æÔò£º)Èç¹ûÒ»¸ö×Ö·û´®ÊôÓÚÒ»¸öÎÄ·¨²úÉúʽ²úÉúµÄÓïÑÔ£¬ÔòËüÆ¥ÅäÕâ¸ö²úÉúʽ¡£(¶ÔÓÚÄÚÈݺÍÄÚÈÝÄ£ÐÍ£º)µ±Ò»¸öÔªËØ·ûºÏ"ÔªËØÓÐЧÐÔ"Ô¼ÊøÖеÄÃèÊöʱ£¬ËüÆ¥ÅäÆäÉùÃ÷.
³öÓÚ¼æÈÝÐÔ¿¼ÂÇ(for compatibility)
½öÓÃÓÚ±£Ö¤ÓëSGML¼æÈݵÄXMLÌØÐÔ¡£
³öÓÚ»¥²Ù×÷ÐÔ¿¼ÂÇ(for interoperability)
ÊÇÒ»¸ö²»¾ßÔ¼ÊøÐԵĽ¨Ò飬ĿµÄÊÇÔö¼ÓXMLÎļþÄܱ»ÔÚISO 8879µÄWebSGML¸Ä±à¸½¼þ֮ǰÒÑÓеÄSGML´¦ÀíÆ÷´¦ÀíµÄ¿ÉÄÜÐÔ¡£

2. Îļþ

Èç¹ûÒ»¸öÊý¾Ý¶ÔÏóÂú×ã±¾¹æ·¶Öй淶µÄ¶¨Òåʱ£¬ËüÊÇÒ»¸öXMLÎļþ¡£Ò»¸ö¹æ·¶µÄXMLÎļþ¿ÉÒÔ¸ü½øÒ»²½ÊÇÓÐЧµÄÈç¹ûËüÂú×ãijЩ½øÒ»²½µÄÔ¼Êø¡£

ÿһ¸öXMLÎļþ¶¼ÓÐÂß¼­ºÍÎïÀí½á¹¹¡£ÎïÀíÉ϶øÑÔ£¬ÎļþÓɳÆΪʵÌåµÄµ¥Ôª×é³É¡£Ò»¸öʵÌå¿ÉÒÔÒýÓÃ(refer)ÆäËûʵÌ壬½«ËüÃÇ°üº¬ÔÚÎļþÖС£Îļþ¿ªÊ¼ÓÚ"¸ù(root)"»òÎļþʵÌåÖС£Âß¼­É϶øÑÔ£¬ÎļþÓÉÉùÃ÷£¬ÔªËØ£¬×¢ÊÍ£¬×Ö·ûÒýÓúʹ¦ÀíÖ¸Áî×é³É£¬ËùÓÐÕâЩ¶¼ÔÚÎļþÖÐÓÃÏÔʽ±ê¼ÇÖ¸Ã÷¡£Âß¼­ºÍÎïÀí½á¹¹±ØÐëÈç"4.3.2 ¹æ·¶µÄÒÑÎöʵÌå"ÖÐËùÃèÊöÄÇÑùÑϸñµØǶÌס£

2.1 ¹æ·¶µÄXMLÎļþ(Well-Formed XML Documents)

Ò»¸öÎı¾¶ÔÏóÊÇÒ»¸ö¹æ·¶µÄXMLÎļþÈç¹ûËüÂú×㣺

  1. ×÷Ϊһ¸öÕûÌ壬ËüÆ¥Åädocument²úÉúʽ¡£
  2. ËüÂú×ã±¾¹æ·¶Öж¨ÒåµÄËùÓй淶ÐÔÔ¼Êø¡£
  3. ´ËÎļþÖÐÖ±½Ó»ò¼ä½ÓÒýÓõÄÿһ¸öÒÑÎöʵÌ嶼Êǹ淶µÄ¡£
Îļþ
[1]  document ::= prolog element Misc*

Æ¥Åädocument²úÉúʽÒâζ×Å£º

  1. Ëü°üº¬Ò»¸ö»ò¶à¸öÔªËØ.
  2. ÓÐÇÒ½öÓÐÒ»¸ö³ÆΪ¸ù(root)»òÎļþÔªËصÄÔªËØ£¬Ëü²»³öÏÖÔÚÆäËûÈκÎÔªËصÄÄÚÈÝ(content)ÖС£¶ÔÓÚÆäËûËùÓÐÔªËØ£¬Èç¹ûÆðʼ±êÇ©ÔÚÁíÒ»¸öÔªËصÄÄÚÈÝÖУ¬ÔòÆä½áÊø±êÇ©Ò²ÔÚͬһԪËصÄÄÚÈÝÖС£»»Ò»¸ö¸ü¼òµ¥µÄ˵·¨£¬ÒÔÆðʼ±êÇ©ºÍ½áÊø±êǩΪ½çµÄ¸÷¸öÔªËØ£¬±ØÐëÑϸñµØǶÌס£

ÕâÑù×öµÄ½á¹ûÊÇ£¬¶ÔÓÚÿһ¸ö·Ç¸ùµÄÔªËØC£¬ÎļþÖÐÁíÓÐÒ»¸öÔªËØP£¬CÔÚPµÄÄÚÈÝÖУ¬¶ø²»ÔÚÆäËûÈκα»PËù°üº¬µÄÔªËصÄÄÚÈÝÖС£P±»³ÆΪCµÄ¸¸ÔªËØ(parent)£¬¶øC±»³ÆΪPµÄ×ÓÔªËØ(child)¡£

2.2 ×Ö·û

Ò»¸öÒÑÎöʵÌå°üº¬Îı¾(text)£¬Îı¾ÊÇÒ»¸ö×Ö·û(character)ÐòÁУ¬¿ÉÒÔ±íʾ±ê¼Ç»ò×Ö·ûÊý¾Ý¡£Ò»¸ö×Ö·ûÊÇISO/IEC 10646[ISO/IEC 10646]Öж¨ÒåµÄÎı¾×îСµ¥Ôª¡£ºÏ·¨µÄ×Ö·û°üÀ¨ÖƱí·û£¬»Ø³µ£¬»»ÐÐÒÔ¼°UnicodeºÍISO/IEC 10646Öж¨ÒåµÄºÏ·¨µÄͼÐÎ×Ö·û¡£²»ÌᳫʹÓÃ[Unicode]6.8½ÚÖж¨ÒåµÄ"¼æÈÝ×Ö·û(compatibility characters)"¡£

×Ö·û·¶Î§
[2]  Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] /* ³ýÁËÌæ´ú¿é(surrogate block)£¬FFFEºÍFFFFÒÔÍâµÄÈÎÒâUnicode×Ö·û¡£*/

½«×Ö·û´úÂë±àÂë³ÉλģÐ͵ĻúÖƸ÷¸öʵÌå¼ä¿ÉÄÜ»áÓÐËù²»Í¬¡£ËùÓеÄXML´¦ÀíÆ÷±ØÐë½ÓÊÜ10646ÖеÄUTF-8ºÍUTF-16±àÂ룻ÓÃÓÚÖ¸³öËùÓñàÂë»òÖ¸¶¨Ê¹ÓÃÆäËû±àÂëµÄ»úÖÆÔÚºóÃæµÄ"4.3.3 ÊµÌåÖеÄ×Ö·û±àÂë"ÖÐÌÖÂÛ¡£

2.3 ͨÓÃÓï·¨³É·Ö

±¾½ÚÖж¨ÒåÁËһЩÔÚÎÄ·¨Öй㷺ʹÓõķûºÅ¡£

S(¿Õ°×)°üÀ¨Ò»¸ö»ò¶à¸ö¿Õ¸ñ×Ö·û(#x20)£¬»Ø³µ£¬»»ÐкÍÖƱí·û¡£

¿Õ°×
[3]  S ::= (#x20 | #x9 | #xD | #xA)+

Ϊ·½±ãÆð¼û£¬×Ö·û±»·ÖΪ×Öĸ£¬Êý×ÖºÍÆäËû×Ö·ûÈýÀà¡£×Öĸ¿ÉÒÔÊÇ×Öĸ±íÖеÄ×Öĸ£¬»òÊÇÒ»¸öÒô½Ú»ù×Ö·û(syllabic base character)ºó¸úÒ»¸ö»ò¶à¸ö×éºÏ×Ö·û£¬Ò²¿ÉÒÔÊÇÒ»¸ö±íÒâ×Ö·û¡£ÔÚ"B. ×Ö·ûµÄ·ÖÀà"Öиø³öÁËÿһÀà×Ö·ûµÄÍêÕû¶¨Òå¡£

Ãû×Ö(name)ÊÇÒÔ×Öĸ»òijЩ±êµã·ûºÅ¿ªÍ·µÄ¼ÇºÅ£¬ºó¸ú×Öĸ£¬Êý×Ö£¬Á¬×Ö·û£¬Ï»®Ïߣ¬Ã°ºÅ»ò¾äºÅ£¬ÕâЩ·ûºÅͳ³ÆΪÃüÃû×Ö·û(name character)¡£ÒÔ"xml"»òÆäËûÈκÎÆ¥Åä (('X'|'x') ('M'|'m') ('L'|'l')) µÄ×Ö·û´®¿ªÍ·µÄÃû×Ö£¬±»±£ÁôÓÃÓÚ±¾¹æ·¶µÄ´Ë°æ±¾»òºóÐø°æ±¾µÄ±ê×¼»¯¡£

×¢Ò⣺XMLÃû×ÖÖеÄðºÅ±»±£ÁôÓÃÓÚÃû×Ö¿Õ¼ä(name space)ʵÑé¡£ËüµÄº¬ÒåÓдýÓÚÈÕºó±ê×¼»¯£¬ÄÇʱÄÇЩ½«Ã°ºÅÓÃÓÚʵÑéÄ¿µÄµÄÎļþÓпÉÄÜÐèÒª¸üС£(²»±£Ö¤XML²ÉÓõÄÈκÎÃû×Ö¿Õ¼ä»úÖÆ»áʵ¼Ê²ÉÓÃðºÅ×÷Ϊ¶¨½ç·û¡£)ʵ¼ÊÉÏ£¬ÕâÒâζ×ųý·ÇÓÃÓÚÃû×Ö¿Õ¼äʵÑ飬XMLÎļþ×÷Õß²»Ó¦¸ÃÔÚXMLÃû×ÖÖÐʹÓÃðºÅ£¬µ«XML´¦ÀíÆ÷Ó¦¸Ã½ÓÊÜðºÅ×÷Ϊһ¸öÃüÃû×Ö·û¡£

Nmtoken(Ãû×ּǺţ¬name token)ÊÇÈκÎÃüÃû×Ö·ûµÄ»ìºÏÌå¡£

Ãû×ֺͼǺÅ
[4]  NameChar ::= LetterDigit | '.' | '-' | '_' | ':' | CombiningCharExtender
[5]  Name ::= (Letter | '_' | ':') (NameChar)*
[6]  Names ::= Name (S Name)*
[7]  Nmtoken ::= (NameChar)+
[8]  Nmtokens ::= Nmtoken (S Nmtoken)*

³£Á¿Êý¾ÝÊÇÈκÎÓÃÒýºÅÀ¨ÆðµÄ×Ö·û´®£¬²»°üÀ¨ÓÃ×÷¶¨½ç·ûµÄÒýºÅ¡£³£Á¿ÓÃÓÚÖ¸Ã÷ÄÚ²¿ÊµÌåµÄÄÚÈÝ(EntityValue)£¬ÊôÐÔÖµ(AttValue)£¬ÒÔ¼°Íⲿ±êʶ·û(SystemLiteral)¡£×¢Ò⣬¶ÔSystemLiteralµÄÓï·¨·ÖÎö¿ÉÒÔ²»É¨Ãè±ê¼Ç¡£

³£Á¿
[9]  EntityValue ::= '"' ([^%&"] | PEReferenceReference)* '"'
¡¡ ¡¡ ¡¡ | "'" ([^%&'] | ¸ href="#NT-PEReference">PEReferenceReference)* "'"
[10]  AttValue ::= '"' ([^<&"] | Reference)* '"'
¡¡ ¡¡ ¡¡ | "'" ([^<&'] | Reference)* "'"
[11]  SystemLiteral ::= ('"' [^"]* '"') | "'" [^']* "'")
[12]  PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'"
[13]  PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]

2.4 ×Ö·ûÊý¾ÝºÍ±ê¼Ç

Îı¾ÓÉ×Ö·ûÊý¾ÝºÍ±ê¼Ç»ìºÏ¹¹³É¡£±ê¼Ç°üÀ¨Æðʼ±êÇ©£¬½áÊø±êÇ©£¬¿ÕÔªËرêÇ©£¬ÊµÌåÒýÓã¬×Ö·ûÒýÓã¬×¢ÊÍ£¬CDATA¶Î¶¨½ç·û£¬ÎļþÀàÐÍÉùÃ÷ºÍ´¦ÀíÖ¸Áî¡£

ÆäËûËùÓзDZê¼ÇµÄÎı¾×é³ÉÎļþµÄ×Ö·ûÊý¾Ý¡£

"and"ºÅ(&)ºÍ×ó¼âÀ¨ºÅ(<)Ö»ÓÐ×÷Ϊ±ê¼Ç¶¨½ç·û£¬»òÔÚ×¢ÊÍ£¬´¦ÀíÖ¸Á»òCDATA¶ÎÖÐʱ²ÅÄÜÒÔ³£Á¿ÐÎʽ³öÏÖ¡£ËüÃÇÔÚÒ»¸öÄÚ²¿ÊµÌåÉùÃ÷µÄ³£Á¿ÊµÌåÊýÖµÖÐÒ²ÊǺϷ¨µÄ£¬²Î¼û"4.3.2 ¹æ·¶µÄÒÑÎöʵÌå"¡£Èç¹ûÔÚÆäËûµØ·½ÐèÒªÓõ½ÕâÁ½¸ö×Ö·û£¬ËüÃDZØÐëÓÃÊýֵʽ×Ö·ûÒýÓÃÀ´×ªÒå»ò·Ö±ðÓÃ×Ö·û´®"&amp;"ºÍ"&lt;"±íʾ¡£ÓÒ¼âÀ¨ºÅ(>)¿ÉÒÔÓÃ"&gt;"±íʾ£¬¶øµ±ËüÔÚÄÚÈÝÖеÄ×Ö·û´®"]]>"ÖгöÏÖ£¬µ«´Ë×Ö·û´®²»±íʾһ¸öCDATA¶ÎµÄ½áÊøʱ£¬³öÓÚ¼æÈÝÐÔ¿¼ÂÇ£¬±ØÐëÓÃ"&gt;"»òÒ»¸ö×Ö·ûÒýÓÃתÒåµÃµ½¡£

ÔÚÒ»¸öÔªËصÄÄÚÈÝÖУ¬×Ö·ûÊý¾Ý¿ÉÒÔÊDz»°üÀ¨Èκαê¼ÇµÄÆðʼ¶¨½ç·ûµÄÈÎÒâ×Ö·û´®¡£ÔÚÒ»¸öCDATA¶ÎÖУ¬×Ö·ûÊý¾Ý¿ÉÒÔÊDz»°üÀ¨CDATA¶Î½áÊø¶¨½ç·û"]]>"µÄÈÎÒâ×Ö·û´®¡£

ΪÁËÔÊÐíÔÚÊôÐÔÖµÖаüº¬µ¥ÒýºÅºÍË«ÒýºÅ£¬Ê¡ÂÔ·û»ò³Æµ¥ÒýºÅ(')¿ÉÒÔ±»±íʾΪ"&apos;"£¬¶øË«ÒýºÅ(")¿ÉÒÔ±»±íʾΪ"&quot;"¡£

×Ö·ûÊý¾Ý
[14]  CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)

2.5 ×¢ÊÍ

×¢ÊÍ¿ÉÒÔÔÚÆäËû±ê¼ÇÖ®ÍâµÄÎļþÖеÄÈκÎλÖóöÏÖ¡£ÁíÍ⣬ËüÃÇ¿ÉÒÔÔÚÎļþÀàÐÍÉùÃ÷ÖÐÎÄ·¨ÔÊÐíµÄµØ·½³öÏÖ¡£ËüÃDz»ÊÇÎļþ×Ö·ûÊý¾ÝµÄÒ»²¿·Ö£¬XML´¦ÀíÆ÷¿ÉÒÔ£¬µ«²»ÊDZØÐ룬ÔÊÐíÒ»¸öÓ¦ÓüìË÷×¢ÊÍÎı¾¡£³öÓÚ¼æÈÝÐÔ¿¼ÂÇ£¬×Ö·û´®"--"(Ë«Á¬×Ö·û)²»ÄÜÔÚ×¢ÊÍÖгöÏÖ¡£

×¢ÊÍ
[15]  Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'

×¢Ê͵ÄÒ»¸öÀý×Ó£º

<!-- declarations for <head> & <body> -->

2.6 ´¦ÀíÖ¸Áî

´¦ÀíÖ¸Áî(PI)ÔÊÐíÎļþÖаüº¬ÓÉÓ¦ÓÃÀ´´¦ÀíµÄÖ¸Áî¡£

´¦ÀíÖ¸Áî
[16]  PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
[17]  PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))

PI²»ÊÇÎļþ×Ö·ûÊý¾ÝµÄÒ»²¿·Ö£¬µ«±ØÐë´«µÝ¸øÓ¦Óá£PIÒÔÓÃÓÚָʾ´«µÝ¸øÄĸöÓ¦ÓõÄÄ¿±ê(PITarget)¿ªÍ·£¬Ä¿±êÃû×Ö"XML"£¬"xml"£¬µÈµÈ£¬±£ÁôÓÃÓÚ±¾¹æ·¶µÄ´Ë°æ±¾»òºóÐø°æ±¾µÄ±ê×¼»¯¡£XML¼Ç·¨»úÖÆ¿ÉÒÔÓÃÓÚPIÄ¿±êµÄÐÎʽ»¯ÉùÃ÷¡£

2.7 CDATA¶Î

CDATA¶Î¿ÉÒÔ³öÏÖÔÚ×Ö·ûÊý¾Ý¿ÉÒÔ³öÏÖµÄÈκεط½£¬ËüÃÇÓÃÓÚתÒå°üº¬»á±»Ê¶±ðΪ±ê¼ÇµÄ×Ö·û´®µÄÎı¾¿é¡£CDATA¶ÎÒÔ×Ö·û´®"<![CDATA["¿ªÊ¼£¬ÒÔ×Ö·û´®"]]>"½áÊø£º

CDATA¶Î
[18]  CDSect ::= CDStart CData CDEnd
[19]  CDStart ::= '<![CDATA['
[20]  CData ::= (Char* - (Char* ']]>' Char*))
[21]  CDEnd ::= ']]>'

ÔÚÒ»¸öCDATA¶ÎÄÚ£¬Ö»ÓÐCDEnd×Ö·û´®±»Ê¶±ðΪ±ê¼Ç£¬Òò´Ë×ó¼âÀ¨ºÅºÍ"&"¿ÉÒÔÒÔËüÃǵij£Á¿ÐÎʽ³öÏÖ£¬²»ÐèÒª(Ò²²»ÄÜ)±»»»ÂëΪ"&lt;"ºÍ"&amp;"¡£CDATA¶Î²»ÄÜǶÌס£

Ò»¸öCDATA¶ÎµÄÀý×Ó£¬ÆäÖÐ"<greeting>"ºÍ"</greeting>"±»Ê¶±ðΪ×Ö·ûÊý¾Ý£¬¶ø²»ÊDZê¼Ç£º

<![CDATA[<greeting>Hello, world!</greeting>]]>

2.8 Ðò(prolog)ºÍÎļþÀàÐÍÉùÃ÷

XMLÎļþ¿ÉÒÔ£¬Ò²Ó¦¸ÃÒÔÒ»¸öXMLÉùÃ÷¿ªÊ¼£¬ÆäÖÐÖ¸Ã÷ÁËËùÓÃXMLµÄ°æ±¾¡£ ÀýÈ磬ÒÔÏÂÊÇÒ»¸öÍêÕûµÄXMLÎļþ£¬ËüÊǹ淶µÄ£¬µ«²»ÊÇÓÐЧµÄ£º

<?xml version="1.0"?>
<greeting>Hello, world!</greeting>

ÏÂÃæÕâ¸öҲͬÑù£º

<greeting>Hello, world!</greeting>

°æ±¾ºÅ"1.0"Ó¦¸ÃÓÃÓÚ±íÃ÷¶ÔÓë¹æ·¶´Ë°æ±¾ÏàÒ»Ö£¬Èç¹ûʹÓÃÁËÖµ"1.0"µ«ÓÖÓë±¾¹æ·¶µÄ´Ë°æ±¾²»Ò»Ö£¬ÄÇôÕâÊÇÎļþµÄÒ»¸ö´íÎó¡£XML¹¤×÷×é´òË㸳Óè±¾¹æ·¶µÄºóÐø°æ±¾²»Í¬ÓÚ"1.0"µÄÊýÖµ£¬µ«Õâ²¢²»´ú±í¿ª·¢ºóÐø°æ±¾µÄ³Ðŵ£¬Ò²²»´ú±íÈç¹ûÓкóÐø°æ±¾£¬»áʹÓÃÈκÎÌØÊâµÄÃüÃû·½°¸µÄ³Ðŵ¡£ÒòΪ²»ÅųýÓкóÐø°æ±¾µÄ¿ÉÄÜÐÔ£¬ÌṩÁ˱¾¹¹Ôì(construct)×÷Ϊһµ©ÐèҪʱ½øÐÐ×Ô¶¯°æ±¾Ê¶±ðµÄÊֶΡ£µ±´¦ÀíÆ÷ÊÕµ½µÄÎļþ±êÓÐËüÃDz»Ö§³ÖµÄ°æ±¾Ê±£¬¿ÉÒÔ¸ø³öÒ»¸ö´íÎó¡£

XMLÎļþÖбê¼ÇµÄ¹¦ÄÜÊÇÃèÊöÎļþµÄ´æ´¢¸ñʽºÍÂß¼­½á¹¹£¬²¢½«ÊôÐÔ-Öµ¶ÔºÍÂß¼­½á¹¹¹ØÁªÆðÀ´¡£XMLÌṩһÖÖ³ÆΪÎļþÀàÐÍÉùÃ÷µÄ»úÖÆ£¬ÓÃÓÚ¶¨Òå¶ÔÂß¼­½á¹¹µÄÔ¼Êø£¬Ö§³ÖÔ¤¶¨Òå´æ´¢µ¥ÔªµÄʹÓá£Èç¹ûÒ»¸öXMLÎļþÓÐÏàÓ¦µÄÎļþÀàÐÍÉùÃ÷²¢ÇÒËü×ñÑ­ÆäÖеÄÔ¼Êø£¬Ôò³ÆËüÊÇÓÐЧµÄ(valid)¡£

ÎļþÀàÐÍÉùÃ÷±ØÐëλÓÚÎļþµÚÒ»¸öÔªËØ֮ǰ¡£

Ðò
[22]  prolog ::= XMLDecl? Misc* (doctypedecl Misc*)?
[23]  XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
[24]  VersionInfo ::= S 'version' Eq (' VersionNum ' | " VersionNum ")
[25]  Eq ::= S? '=' S?
[26]  VersionNum ::= ([a-zA-Z0-9_.:] | '-')+
[27]  Misc ::= CommentPIS

XMLÎļþÀàÐÍÉùÃ÷°üº¬»òÖ¸Ïòxmlrkupdecl">±ê¼ÇÉùÃ÷£¬±ê¼ÇÉùÃ÷ÌṩijһÀàÎļþµÄÎÄ·¨¡£ÕâÖÖÎÄ·¨±»³ÆΪÎļþÀàÐͶ¨Òå(document type difinition£¬DTD)¡£ÎļþÀàÐͶ¨Òå¿ÉÒÔÖ¸ÏòÒ»¸öÍⲿ×Ó¼¯(Ò»ÖÖÌØÊâÀàÐ͵ÄÍⲿʵÌå)£¬»òÕß¿ÉÒÔÔÚÒ»¸öÄÚ²¿×Ó¼¯ÖÐÖ±½Ó°üº¬±ê¼ÇÉùÃ÷£¬»òÕßÁ½Õß¼æÓá£Ò»¸öÎļþµÄÎļþÀàÐͶ¨ÒåÓÉÕâÁ½¸ö×Ó¼¯ºÏÔÚÒ»Æð×é³É¡£

±ê¼ÇÉùÃ÷¿ÉÒÔÊÇÔªËØÀàÐÍÉùÃ÷£¬ÊôÐÔ±íÉùÃ÷£¬ÊµÌåÉùÃ÷£¬»òÊǼǷ¨ÉùÃ÷¡£ÕâЩÉùÃ÷¿ÉÒÔÈçÏÂÃæ¹æ·¶ÐÔºÍÓÐЧÐÔÔ¼ÊøÖÐËùÊö£¬È«²¿»ò²¿·ÖµØ°üº¬ÔÚ²ÎÊýʵÌåÖУ¬ÍêÕûµÄÐÅÏ¢²Î¼û"4. ÎïÀí½á¹¹"¡£

ÎļþÀàÐͶ¨Òå
[28]  doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S? ('[' (markupdeclPEReferenceS)* ']' S?)? '>' [ VC: ¸ùÔªËØÀàÐÍ ]
[29]  markupdecl ::= elementdeclAttlistDeclEntityDeclNotationDeclPIComment [ VC: ÑϸñµÄÉùÃ÷/PEǶÌ× ]
¡¡ ¡¡ ¡¡ ¡¡ [ WFC: ÄÚ²¿×Ó¼¯ÖеÄPE ]

±ê¼ÇÉùÃ÷¿ÉÒÔÈ«²¿»ò²¿·ÖµØÓɲÎÊýʵÌåµÄÖû»Îı¾×é³É¡£±¾¹æ·¶ºóÃæµÄ¸÷¸ö·ÇÖÕ½á·û(elementdecl£¬AttlistDecl£¬µÈµÈ)²úÉúʽÃèÊöµÄÊÇÔÚËùÓеIJÎÊýʵÌå±»°üº¬(include)Ö®ºóµÄÉùÃ÷¡£

ÓÐЧÐÔÔ¼Êø: ¸ùÔªËØÀàÐÍ(Root Element Type)
ÎļþÀàÐÍÉùÃ÷ÖеÄName±ØÐëÆ¥Åä¸ùÔªËصÄÀàÐÍ¡£

ÓÐЧÐÔÔ¼Êø: ÑϸñµÄÉùÃ÷/PEǶÌ×
²ÎÊýʵÌåµÄÖû»Îı¾±ØÐëÓñê¼ÇÉùÃ÷ÑϸñǶÌס£¼´£¬Èç¹ûÒ»¸ö±ê¼ÇÉùÃ÷(ÉÏÃæµÄmarkupdecl)µÄµÚÒ»¸ö»ò×îºóÒ»¸ö×Ö·û±»°üº¬ÓÚÒ»¸ö²ÎÊýʵÌåÒýÓõÄÖû»Îı¾ÖУ¬Á½Õß±ØÐ붼ÔÚ´ËÖû»Îı¾ÖС£

¹æ·¶ÐÔÔ¼Êø: ÄÚ²¿×Ó¼¯ÖеÄPE
ÔÚÄÚ²¿DTD×Ó¼¯ÖУ¬²ÎÊýʵÌåÒýÓÃÖ»ÄܳöÏÖÔÚ±ê¼ÇÉùÃ÷¿ÉÒÔ³öÏֵĵط½£¬¶ø²»ÄÜÔÚ±ê¼ÇÉùÃ÷ÄÚ²¿³öÏÖ¡£(Õâ¸öÔ¼Êø²»ÊÊÓÃÓÚ³öÏÖÔÚÍⲿ²ÎÊýʵÌåÄÚµÄÒýÓã¬Ò²²»ÊÊÓÃÓÚÍⲿ×Ó¼¯¡£)

ͬÄÚ²¿×Ó¼¯Ò»Ñù£¬Íⲿ×Ó¼¯ºÍÈκÎDTDÖÐÒýÓõÄÍⲿ²ÎÊýʵÌ壬±ØÐëÓÉһϵÁб»·ÇÖÕ½á·ûmarkupdeclËùÔÊÐíµÄÍêÕûµÄ±ê¼ÇÉùÃ÷×é³É£¬ÆäÖпÉÒÔ¼ÐÔÓ¿Õ°××Ö·û»ò²ÎÊýʵÌåÒýÓᣵ«ÊÇ£¬Íⲿ×Ó¼¯ºÍÍⲿ²ÎÊýʵÌåµÄ²¿·ÖÄÚÈÝ¿ÉÒÔͨ¹ýʹÓÃÌõ¼þ¶Î(conditional section)±»ÓÐÌõ¼þµØºöÂÔ£¬ÔÚÄÚ²¿×Ó¼¯ÖÐÔò²»ÔÊÐíÕâô×ö¡£

Íⲿ×Ó¼¯
[30]  extSubset ::= TextDecl? extSubsetDecl
[31]  extSubsetDecl ::= ( markupdeclconditionalSectPEReferenceS )*

Íⲿ×Ó¼¯ºÍÍⲿ²ÎÊýʵÌåÓëÄÚ²¿ÊµÌ岻֮ͬ´¦»¹ÔÚÓÚ£ºÔÚËüÃÇÄÚ£¬²ÎÊýʵÌåÒýÓò»½ö¿ÉÒÔ³öÏÖÔÚ±ê¼ÇÉùÃ÷¼ä£¬»¹¿ÉÒÔ³öÏÖÔÚ±ê¼ÇÉùÃ÷ÄÚ¡£

ÓÐÎļþÀàÐÍÉùÃ÷µÄXMLÎļþµÄÀý×Ó£º

<?xml version="1.0"?>
<!DOCTYPE greeting SYSTEM "hello.dtd">
<greeting>Hello, world!</greeting>

ϵͳ±êʶ·û"hello.dtd"¸ø³öÁËÎļþDTDµÄURI¡£

ÉùÃ÷Ò²¿ÉÒÔÈçͬÏÂÃæÕâ¸öÀý×ÓÒ»ÑùÖ±½Ó(locally)¸ø³ö£º

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE greeting [
  <!ELEMENT greeting (#PCDATA)>
]>
<greeting>Hello, world!</greeting>

Èç¹ûͬʱʹÓÃÍⲿºÍÄÚ²¿×Ó¼¯£¬×Ó¼¯×Ó¼¯±»¿´³É³öÏÖÔÚÍⲿ×Ó¼¯Ö®Ç°£¬ÕâÒâζ×ÅÄÚ²¿×Ó¼¯ÖеÄʵÌåºÍÊôÐÔ±íÉùÃ÷µÄÓÅÏȼ¶Òª±ÈÔÚÍⲿ×Ó¼¯Öеĸߡ£

2.9 ¶ÀÁ¢ÎļþÉùÃ÷

µ±Îļþ´ÓXML´¦ÀíÆ÷µÝ¸øÓ¦ÓÃʱ£¬±ê¼ÇÉùÃ÷¿ÉÒÔÓ°ÏìËüµÄÄÚÈÝ£¬ÊôÐÔȱʡֵºÍʵÌåÉùÃ÷ÊÇÆäÖеÄÀý×Ó¡£¿ÉÒÔ×÷ΪXMLÉùÃ÷³É·ÖµÄ¶ÀÁ¢ÎļþÉùÃ÷£¬Ö¸Ã÷Á˶ÔÓÚÎļþʵÌå¶øÑÔ£¬ÊÇ·ñ´æÔÚÍⲿµÄÉùÃ÷¡£

£¬±ê¼ÇÉùÃ÷ÌṩijһÀàÎļþµÄÎÄ·5DCB3">
¶ÀÁ¢ÎļþÉùÃ÷
[32]  SDDecl ::= S 'standalone' Eq (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"')) [ VC: ¶ÀÁ¢ÎļþÉùÃ÷ ]

ÔÚÒ»¸ö¶ÀÁ¢ÎļþÉùÃ÷ÖУ¬Öµ"yes"±íʾ¶ÔÓÚÎļþʵÌåûÓÐÍⲿ±ê¼ÇÉùÃ÷(²»ÂÛÊÇÔÚDTDÍⲿ×Ó¼¯ÖУ¬»¹ÊÇÔÚÓÉÄÚ²¿ÊµÌåÒýÓõÄÍⲿ²ÎÊýʵÌåÖÐ)»áÓ°Ïì´ÓXML´¦ÀíÆ÷´«µÝ¸øÓ¦ÓõÄÐÅÏ¢¡£Öµ"no"±íʾÓлò¿ÉÄÜÓÐÕâÑùµÄÍⲿ±ê¼ÇÉùÃ÷¡£×¢Òâ¶ÀÁ¢ÎļþÉùÃ÷Ö»ÊDZíʾÍⲿÉùÃ÷µÄ´æÔÚ£¬Èç¹ûÎļþÖдæÔÚ¶ÔÍⲿʵÌåµÄÒýÓ㬶øÕâЩʵÌåÒÑÔÚÄÚ²¿ÉùÃ÷ʱ£¬²»Ó°ÏìËüµÄ¶ÀÁ¢×´Ì¬¡£

Èç¹û²»´æÔÚÍⲿ±ê¼ÇÉùÃ÷£¬¶ÀÁ¢ÎļþÉùÃ÷ûÓÐÒâÒå¡£Èç¹û´æÔÚÍⲿ±ê¼ÇÉùÃ÷£¬µ«Ã»ÓжÀÁ¢ÎļþÉùÃ÷£¬¾Í¼Ù¶¨È¡Öµ"no"¡£

ijЩÍøÂç´«ÊäÓ¦ÓÃÒ²ÐíÐèÒª¶ÀÁ¢µÄÎļþ£¬ÈκÎÂú×ãstandalone="no"µÄXMLÎļþ¿ÉÒÔͨ¹ýÒ»¶¨µÄË㷨ת»»Îª¶ÀÁ¢Îļþ¡£

ÓÐЧÐÔÔ¼Êø: ¶ÀÁ¢ÎļþÉùÃ÷
¶ÀÁ¢ÎļþÉùÃ÷±ØÐëȡֵΪ"no"£¬Èç¹ûÈκÎÍⲿ±ê¼ÇÉùÃ÷Öаüº¬£º

¾ßÓжÀÁ¢ÎļþÉùÃ÷µÄXMLÉùÃ÷µÄÀý×Ó£º

<?xml version="1.0" standalone='yes'?>

2.10 ¿Õ°×´¦Àí

Ôڱ༭XMLÎļþʱ£¬Ê¹ÓÃ"¿Õ°×"(¿Õ¸ñ£¬ÖƱí·û£¬¿ÕÐУ¬ÔÚ±¾¹æ·¶ÖÐÓ÷ÇÖÕ½á·ûS±íʾ)À´·Ö¿ª±ê¼ÇÒÔ»ñµÃ¸üºÃµÄ¿É¶ÁÐÔÊǺܷ½±ãµÄ¡£Í¨³£ÔÚÎļþµÄ½»¸¶°æ±¾Öв»Ïë°üº¬ÕâЩ¿Õ°×¡£ÁíÒ»·½Ã棬±ØÐë±£ÁôÔÚ½»¸¶°æ±¾ÖеÄÓÐÒâÒåµÄ¿Õ°×ÊǺܳ£¼ûµÄ£¬ÈçÔÚÊ«¸èºÍÔ´ÂëÖеĿհס£

XML´¦ÀíÆ÷±ØÐëʼÖհѲ»ÊDZê¼ÇµÄËùÓÐ×Ö·û´«µÝ¸øÓ¦Óᣠһ¸ö½øÐÐÑéÖ¤µÄXML´¦ÀíÆ÷±ØÐëͬʱ֪ͨӦÓÃÕâЩ×Ö·ûÖеÄÄÇһЩ×é³ÉÁ˳öÏÖÔÚÔªËØÐÍÄÚÈÝÖеĿհס£

¿ÉÒÔÔÚÔªËØÖи½¼ÓÒ»¸öÃûΪxml:spaceµÄÌØÊâÊôÐÔ£¬ÒÔ֪ͨӦÓÃÓ¦¸Ã±£Áô´ËÔªËØÖеĿհס£ÔÚÓÐЧµÄÎļþÖУ¬´ËÊôÐÔºÍÆäËûÊôÐÔÒ»Ñù£¬Ê¹ÓÃʱ±ØÐëÉùÃ÷¡£Ëü±ØÐë±»ÉùÃ÷Ϊö¾ÙÀàÐÍ£¬Ö»ÓÐ"default"ºÍ"preserve"Á½¸ö¿ÉÄܵÄÖµ¡£ÀýÈ磺

    <!ATTLIST poem   xml:space (default|preserve) 'preserve'>

"default"±íʾ¿ÉÒÔ¶Ô´ËÔªËØʹÓÃÓ¦ÓõÄȱʡ¿Õ°×´¦Àíģʽ£¬"preserve"±íʾӦÓÃÓ¦¸Ã±£ÁôËùÓеĿհס£ÕâÊÊÓÃÓÚÆäËù´¦ÔªËصÄÄÚÈÝÖеÄËùÓÐÔªËØ£¬³ý·Ç±»ÁíÒ»¸öxml:spaceÊôÐÔµÄʵÀýËù¸²¸Ç¡£

ÈκÎÎļþµÄ¸ùÔªËر»ÈÏΪ¶ÔÓ¦ÓõĿհ״¦Àí·½Ê½²»×÷ÒªÇ󣬳ý·ÇËü¸ø´ËÊôÐÔ¸³ÁËÖµ»ò½«´ËÊôÐÔÉùÃ÷Ϊ´øȱʡֵ¡£

2.11 ÐÐβ´¦Àí

Ϊ±à¼­µÄ·½±ãÆð¼û£¬´æ´¢XMLÒÑÎöʵÌåµÄ¼ÆËã»úÎļþ¾­³£ÓÃÐÐÀ´×éÖ¯¡£Í¨³£ÕâЩÐÐÓûسµ·û(#xD)ºÍ»»Ðзû(#xA)µÄһЩ×éºÏÀ´·Ö¸ô¡£

ΪÁËʹӦÓõŤ×÷¼òµ¥»¯£¬¶ÔÓÚÒ»¸öÍⲿÒÑÎöʵÌå»òÄÚ²¿ÒÑÎöʵÌåµÄ³£Á¿ÊµÌåÖµÖаüº¬µÄÈκÎÁ½×Ö·û³£Á¿ÐòÁÐ"#xD#xA"»òµ¥¶ÀµÄ³£Á¿#xD£¬XML´¦ÀíÆ÷¶¼Ó¦»»³É#xA´«µÝ¸øÓ¦Óá£(Õâ¿ÉÒÔͨ¹ýÔÚ½øÐÐÓï·¨·ÖÎöÇ°½«ËùÓÐÐзָô·û¹æ·¶³É#xA¶ø·½±ãµØʵÏÖ¡£)

2.12 ÓïÑÔ±êʶ

ÔÚ½øÐÐÎļþ´¦Àíʱ£¬±êʶ³öÆäÄÚÈÝËùʹÓõÄ×ÔÈ»»òÐÎʽ»¯ÓïÑÔ¾­³£ÊǺÜÓÐÓõġ£¿ÉÒÔÔÚÎļþÖвåÈëÒ»¸öÃûΪxml:langµÄÌØÊâÊôÐÔÓÃÓÚÖ¸³öXMLÎļþÖÐÈκÎÔªËصÄÄÚÈݺÍÊôÐÔËùʹÓõÄÓïÑÔ¡£ÔÚÓÐЧµÄÎļþÖУ¬´ËÊôÐÔºÍÆäËûÊôÐÔÒ»Ñù£¬Ê¹ÓÃʱ±ØÐëÉùÃ÷¡£´ËÊôÐÔµÄÖµÊÇ[IETF RFC 1766]£¬"ÓïÑÔ±êʶÂë"Öж¨ÒåµÄÓïÑÔ±êʶ·û£º

ÓïÑÔ±êʶ
[33]  LanguageID ::= Langcode ('-' Subcode)*
[34]  Langcode ::= ISO639CodeIanaCodeUserCode
[35]  ISO639Code ::= ([a-z] | [A-Z]) ([a-z] | [A-Z])
[36]  IanaCode ::= ('i' | 'I') '-' ([a-z] | [A-Z])+
[37]  UserCode ::= ('x' | 'X') '-' ([a-z] | [A-Z])+
[38]  Subcode ::= ([a-z] | [A-Z])+

Langcode¿ÉÒÔÊÇÏÂÁÐÖµ£º

¿ÉÒÔÓÐÈÎÒâ¶à¸öSubcode¶Î£¬Èç¹ûµÚÒ»¸ö×Ó´úÂë¶Î´æÔÚ£¬²¢ÇÒ×Ó´úÂëÓÉÁ½¸ö×Öĸ×é³É£¬ÄÇô´Ë×Ó´úÂë±ØÐëÊÇ[ISO 3166]£¬"¹ú¼ÒÃû³ÆµÄ±íʾÂë"Öж¨ÒåµÄ¹ú¼Ò´úÂë¡£Èç¹ûµÚÒ»¸ö×Ó´úÂë¶àÓÚÁ½¸ö×Öĸ£¬ÄÇôËü±ØÐëÊÇÔÚIANA×¢²áµÄÓïÑÔ´úÂëËù±íʾµÄÓïÑÔµÄ×Ó´úÂ룬³ý·ÇËüLangcodeÒÔǰ׺"x-"»ò"X-"¿ªÍ·¡£

Ï°¹ßÉÏÓÃСд×Öĸ¸ø³öÓïÑÔ´úÂ룬Óôóд×Öĸ¸ø³ö¹ú¼Ò´úÂë(Èç¹ûÓеĻ°)¡£×¢ÒâÕâЩֵÓëXMLÎļþÖеÄÆäËûÃû×Ö²»Í¬£¬ÊÇ´óСдÎ޹صġ£

¾ÙÀýÈçÏ£º

<p xml:lang="en">The quick brown fox jumps over the lazy dog.</p>
<p xml:lang="en-GB">What colour is it?</p>
<p xml:lang="en-US">What color is it?</p>
<sp who="Faust" desc='leise' xml:lang="de">
  <l>Habe nun, ach! Philosophie,</l>
  <l>Juristerei, und Medizin</l>
  <l>und leider auch Theologie</l>
  <l>durchaus studiert mit heißem Bemüh'n.</l>
  </sp>

xml:langËù±íʾµÄÓïÑÔÑ¡ÔñÊÊÓÃÓÚËüËù´¦ÔªËصÄËùÓÐÊôÐÔºÍÄÚÈÝ£¬³ý·Ç±»´ËÄÚÈÝÖеÄÔªËØÄÚµÄÁíÒ»¸öxml:langµÄʵÀýËù¸²¸Ç¡£

xml:langµÄÒ»¸ö¼òµ¥ÉùÃ÷¿ÉÒÔ²ÉÓÃÈçÏÂÐÎʽ£º

xml:lang  NMTOKEN  #IMPLIED

µ«ÊÇÈç¹ûºÏÊʵĻ°£¬Ò²¿ÉÒÔ¸ø³öÌض¨µÄȱʡֵ¡£ÔÚÒ»±¾¹©Ó¢¹úѧÉúʹÓõķ¨ÎÄÊ«¸è¼¯ÖУ¬ÆÀ×¢ºÍ×¢½âʹÓÃÓ¢Óxml:langÊôÐÔ¿ÉÒÔÕâÑùÉùÃ÷£º

    <!ATTLIST poem   xml:lang NMTOKEN 'fr'>
    <!ATTLIST gloss  xml:lang NMTOKEN 'en'>
    <!ATTLIST note   xml:lang NMTOKEN 'en'>

3. Âß¼­½á¹¹

ÿ¸öXMLÎļþ°üº¬Ò»¸ö»ò¶à¸öÔªËØ£¬ËüÃǵı߽çÓÃÆðʼ±êÇ©ºÍ½áÊø±êÇ©·Ö¸ô£¬»òÕߣ¬¶ÔÓÚ¿ÕÔªËØ£¬ÓÃÒ»¸ö¿ÕÔªËرêÇ©·Ö¸ô¡£Ã¿Ò»¸öÔªËØÓÐÒ»¸öÓÃÃû×Ö±êʶµÄÀàÐÍ£¬ÓÐʱ³Æ֮ΪËüµÄ"ͨÓñêʶ·û(generic identifier)"(GI)£¬Í¬Ê±Ëü¿ÉÒÔÓÐÒ»¸öÊôÐÔֵ˵Ã÷(attribute specification)¼¯¡£Ã¿Ò»¸öÊôÐÔֵ˵Ã÷ÓÐÒ»¸öÃû×ÖºÍÒ»¸öÖµ¡£

ÔªËØ
[39]  element ::= EmptyElemTag
¡¡ ¡¡ ¡¡ STag content ETag [ WFC: ÔªËØÀàÐÍÆ¥Åä ]
¡¡ ¡¡ ¡¡ ¡¡ [ VC: ÔªËØÓÐЧÐÔ ]

³ýÁËÄÇЩ¿ªÍ·Æ¥Åä(('X'|'x')('M'|'m')('L'|'l'))µÄÃû×Ö±£ÁôÓÃÓÚ±¾¹æ·¶µÄ´Ë°æ±¾ºÍºó¼Ì°æ±¾µÄ±ê×¼»¯Í⣬±¾¹æ·¶²»¶ÔÔªËØÀàÐͺÍÊôÐÔµÄÓïÒ壬Ó÷¨ºÍÃû×Ö(Óï·¨Ö®Íâ)×÷³öÏÞÖÆ¡£

¹æ·¶ÐÔÔ¼Êø: ÔªËØÀàÐÍÆ¥Åä
ÔªËؽáÊø±êÇ©ÖеÄName±ØÐëºÍÆðʼ±êÇ©ÖеÄÔªËØÀàÐÍÏàÆ¥Åä¡£

ÓÐЧÐÔÔ¼Êø: ÔªËØÓÐЧÐÔ
Èç¹ûÓÐÒ»¸öÓëelementdeclÏàÆ¥ÅäµÄÉùÃ÷µÄNameÓëÔªËØÀàÐÍÏàÆ¥Å䣬ÇÒÏÂÊöÖ®Ò»³ÉÁ¢Ê±£¬³Æ´ËÔªËØÊÇÓÐЧµÄ£º

  1. ´ËÉùÃ÷ÓëEMPTYÏàÆ¥Å䣬ͬʱ´ËÔªËØûÓÐÄÚÈÝ¡£
  2. ´ËÉùÃ÷ÓëchildrenÏàÆ¥Å䣬ͬʱ×ÓÔªËصÄÐòÁÐÊôÓÚÄÚÈÝÄ£ÐÍÖеÄÕýÔò±í´ïʽËù²úÉúµÄÓïÑÔ£¬ÔÚÿ¶Ô×ÓÔªËؼäÔÊÐíÓпհ×(Æ¥Åä·ÇÖÕ½á·ûSµÄ×Ö·û)¡£
  3. ´ËÉùÃ÷ÓëMixedÏàÆ¥Å䣬ͬʱÄÚÈÝÓÉÆäÀàÐÍÆ¥ÅäÄÚÈÝÄ£ÐÍÖеÄÃû×ÖµÄ×Ö·ûÊý¾ÝºÍ×ÓÔªËØ×é³É¡£
  4. ´ËÉùÃ÷ÓëANYÏàÆ¥Å䣬ͬʱÿ¸ö×ÓÔªËصÄÀàÐ;ùÒÑÉùÃ÷¡£

3.1 Æðʼ±êÇ©£¬½áÊø±êÇ©ºÍ¿ÕÔªËرêÇ©

ÿһ¸ö·Ç¿ÕXMLÔªËØÒÔÒ»¸öÆðʼ±êÇ©×÷Ϊ¿ªÊ¼µÄ±ê¼Ç¡£

Æðʼ±êÇ©
[40]  STag ::= '<' Name (S Attribute)* S? '>' [ WFC: ΨһµÄÊôÐÔֵ˵Ã÷ ]
[41]  Attribute ::= Name Eq AttValue [ VC: ÊôÐÔÖµÀàÐÍ ]
¡¡ ¡¡ ¡¡ ¡¡ [ WFC: ÎÞÍⲿʵÌåÒýÓà ]
¡¡ ¡¡ ¡¡ ¡¡ [ WFC: ÔÚÊôÐÔÖµÖÐûÓÐ< ]

Æðʼ±êÇ©ºÍ½áÊø±êÇ©ÖеÄName¸ø³öÁËÔªËصÄÀàÐÍ¡£Name-AttValue¶Ô±»Í³³ÆΪԪËصÄÊôÐÔֵ˵Ã÷£¬ÆäÖÐÿһ¶ÔÖеÄName±»³ÆΪÊôÐÔÃû£¬AttValueµÄÄÚÈÝ(ÔÚ'»ò"¶¨½ç·û¼äµÄÎı¾)±»³ÆΪÊôÐÔÖµ¡£

¹æ·¶ÐÔÔ¼Êø: ΨһµÄÊôÐÔֵ˵Ã÷
Ò»¸öÊôÐÔÃûÖ»ÄÜÔÚͬһ¸öÆðʼ±êÇ©»ò¿ÕÔªËرêÇ©ÖгöÏÖÒ»´Î¡£

ÓÐЧÐÔÔ¼Êø: ÊôÐÔÖµÀàÐÍ
ÊôÐÔ±ØÐë±»ÉùÃ÷£¬ÆäÖµ±ØÐë¾ßÓÐËùÉùÃ÷µÄÀàÐÍ¡£(ÊôÐÔÀàÐͲμû"3.3 ÊôÐÔ±íÉùÃ÷"¡£)

¹æ·¶ÐÔÔ¼Êø: ÎÞÍⲿʵÌåÒýÓÃ
ÊôÐÔÖµ²»ÄÜ°üº¬¶ÔÍⲿʵÌåÖ±½Ó»ò¼ä½ÓµÄʵÌåÒýÓá£

¹æ·¶ÐÔÔ¼Êø: ÔÚÊôÐÔÖµÖÐûÓÐ<
ÔÚÒ»¸öÊôÐÔÖµÖÐÖ±½Ó»ò¼ä½ÓÒýÓõÄʵÌåµÄÖû»Îı¾(³ýÁË"&lt;")²»ÄÜ°üº¬<¡£

Æðʼ±êÇ©µÄÒ»¸öÀý×Ó£º

<termdef id="dt-dog" term="dog">

ÓÉÒ»¸öÆðʼ±êÇ©¿ªÊ¼µÄÿһ¸öÔªËرØÐëÓÃÒ»¸ö½áÊø±êÇ©±ê¼ÇÆä½áÊø£¬½áÊø±êÇ©ÖеÄÃû×Ö±ØÐëÓëÆðʼ±êÇ©Öиø³öµÄÔªËØÀàÐÍÏàͬ£º

½áÊø±êÇ©
[42]  ETag ::= '</' Name S? '>'

½áÊø±êÇ©µÄÒ»¸öÀý×Ó£º

</termdef>

ÔÚÆðʼ±êÇ©ºÍ½áÊø±êÇ©ÖеÄÎı¾±»³ÆΪԪËصÄÄÚÈÝ£º

ÔªËصÄÄÚÈÝ
[43]  content ::= (elementCharDataReferenceCDSectPIComment)*

Èç¹ûÔªËصÄÄÚÈÝΪ¿Õ£¬Ëü±ØÐë±íʾΪһ¸öÆðʼ±êÇ©½ô¸úÒ»¸ö½áÊø±êÇ©»ò¿ÕÔªËرêÇ©¡£¿ÕÔªËرêÇ©Ôò²ÉÓÃÒ»ÖÖÌØÊâµÄÐÎʽ£º

¿ÕÔªËرêÇ©
[44]  EmptyElemTag ::= '<' Name (S Attribute)* S? '/>' [ WFC: ΨһµÄÊôÐÔֵ˵Ã÷ ]

²»ÂÛÔªËØÊÇ·ñÓùؼü×ÖEMPTYÉùÃ÷£¬¿ÕÔªËرêÇ©¶¼¿ÉÒÔÓÃÓÚÈκÎûÓÐÄÚÈݵÄÔªËØ¡£³öÓÚ»¥²Ù×÷ÐÔ¿¼ÂÇ£¬¿ÕÔªËرØÐëÓÃÓÚ£¬ÇÒÖ»ÄÜÓÃÓÚÉùÃ÷ΪEMPTYµÄÔªËØ¡£

¿ÕÔªËصÄÀý×Ó£º

<IMG align="left"
 src="http://www.w3.org/Icons/WWW/w3c_home" />
<br></br>
<br/>

3.2 ÔªËØÀàÐÍÉùÃ÷

³öÓÚÑéÖ¤µÄÄ¿µÄ£¬¿ÉÒÔÓÃÔªËØÀàÐͺÍÊôÐÔ±íÉùÃ÷ÏÞÖÆXMLÎļþÖÐÔªËصĽṹ¡£ÔªËØÀàÐÍÉùÃ÷ÏÞÖÆÁËÔªËصÄÄÚÈÝ¡£

ÔªËØÀàÐÍÉùÃ÷ͨ³£ÏÞÖÆÁË×ÓÔªËصÄÀàÐÍ¡£ÓÉÓû§Ñ¡Ôñ£¬µ±ÉùÃ÷Ìáµ½µÄÔªËØÀàÐÍûÓÐÏàÓ¦µÄÉùÃ÷ʱ£¬XML´¦ÀíÆ÷¿ÉÒÔ¸ø³ö¾¯¸æ£¬µ«Õâ²»ÊÇÒ»¸ö´íÎó¡£

ÔªËØÀàÐÍÉùÃ÷ÐÎʽÈçÏ£º

ÔªËØÀàÐÍÉùÃ÷
[45]  elementdecl ::= '<!ELEMENT' S Name S contentspec S? '>' [ VC: ΨһµÄÔªËØÀàÐÍÉùÃ÷ ]
[46]  contentspec ::= 'EMPTY' | 'ANY' | Mixedchildren

ÆäÖÐName¸ø³öÁËËùÉùÃ÷µÄÔªËØÀàÐÍ¡£

ÓÐЧÐÔÔ¼Êø: ΨһµÄÔªËØÀàÐÍÉùÃ÷
ÔªËØÀàÐÍÖ»ÄÜÉùÃ÷Ò»´Î¡£

ÔªËØÀàÐÍÉùÃ÷µÄÀý×Ó£º

<!ELEMENT br EMPTY>
<!ELEMENT p (#PCDATA|emph)* >
<!ELEMENT %name.para; %content.para; >
<!ELEMENT container ANY>

3.2.1 ÔªËØÐÍÄÚÈÝ

µ±Ä³Ò»ÀàÐ͵ÄÔªËØÖ»ÄÜ°üº¬ÓÿÉÑ¡¿Õ°×(Æ¥Åä·ÇÖÕ½á·ûS)·Ö¸ôµÄ×ÓÔªËØ(ÎÞ×Ö·ûÊý¾Ý)ʱ£¬³Æ´ËÔªËØÀàÐ;ßÓÐÔªËØÐÍÄÚÈÝ¡£ÔÚÕâÖÖÇé¿öÏ£¬ÓÐÄÚÈÝÄ£ÐÍ×÷ΪÀàÐÍÏÞÖÆÖ®Ò»£¬ÄÚÈÝÄ£ÐÍÊǾö¶¨×ÓÔªËØÀàÐͺÍ×ÓÔªËسöÏÖ˳ÐòµÄÒ»ÖÖ¼òµ¥ÎÄ·¨¡£´ËÎÄ·¨ÓÃÄÚÈÝÁ£×Ó(cp)¹¹½¨£¬ÄÚÈÝÁ£×ÓÓÉÃû×Ö£¬ÄÚÈÝÁ£×ÓµÄÑ¡Ôñ±í(choice list)»òÄÚÈÝÁ£×ÓµÄÐòÁбí(sequence list)×é³É£º

ÔªËØÐÍÄÚÈݵÄÄ£ÐÍ
[47]  children ::= (choiceseq) ('?' | '*' | '+')?
[48]  cp ::= (Namechoiceseq) ('?' | '*' | '+')?
[49]  choice ::= '(' S? cp ( S? '|' S? cp )* S? ')' [ VC: ÑϸñµÄ×é/PEǶÌ× ]
[50]  seq ::= '(' S? cp ( S? ',' S? cp )* S? ')' [ VC: ÑϸñµÄ×é/PEǶÌ× ]

ÆäÖÐÿһ¸öNameÊÇ¿ÉÒÔ×÷Ϊ×ÓÔªËصÄÔªËصÄÀàÐÍ¡£Ñ¡Ôñ±íÖгöÏÖµÄÈÎÒâÄÚÈÝÁ£×ÓÔÚÔªËØÐÍÄÚÈÝÖÐÔÊÐí³öÏÖµÄλÖöÔÓ¦ÓÚÑ¡Ôñ±íÔÚÎÄ·¨ÖеÄλÖá£ÐòÁбíÖгöÏÖµÄËùÓÐÄÚÈÝÁ£×Ó±ØÐëÒÔÏàͬµÄ˳Ðò³öÏÖÔÚÔªËØÐÍÄÚÈÝÖС£ÔÚÃû×Ö»ò±íÖ®ºóµÄ¿ÉÑ¡×Ö·û(optional character)¾ö¶¨Á˱íÖÐÔªËØ»òÄÚÈÝÁ£×Ó¿ÉÒÔ³öÏÖÒ»´Î»ò¶à´Î(+)£¬»¹ÊÇÁã´Î»ò¶à´Î(*)£¬»òÊÇÁã´Î»òÒ»´Î(?)¡£Ã»ÓÐÕâÑùÒ»¸ö²Ù×÷·ûÒâζ×ÅÔªËØ»òÄÚÈÝÁ£×Ó±ØÐëÇ¡ºÃ³öÏÖÒ»´Î¡£ÕâÖÖÓï·¨ºÍÒâÒåºÍ±¾¹æ·¶ÖеIJúÉúʽÖÐËùʹÓõÄÏàͬ¡£

µ±ÇÒ½öµ±Ò»¸öÔªËصÄÄÚÈÝ¿ÉÒÔͨ¹ýÂú×ãÄÚÈÝÄ£ÐÍÖеÄÑ¡Ôñ£¬ÐòÁкÍÖظ´²Ù×÷·ûµÃµ½£¬²¢ÇÒÄÚÈÝÖеÄÿһ¸öÔªËØÓëÄÚÈÝÄ£ÐÍÖеÄÒ»ÖÖÔªËØÀàÐÍÏàÆ¥Åäʱ£¬³Æ´ËÔªËصÄÄÚÈÝÓë¸ÃÄÚÈÝÄ£ÐÍÏàÆ¥Åä¡£³öÓÚ¼æÈÝÐÔ¿¼ÂÇ£¬ Èç¹ûÎļþµÄij¸öÔªËØ¿ÉÒÔºÍÄÚÈÝÄ£ÐÍÖеÄÒ»ÖÖÔªËØÀàÐͶà´ÎÆ¥Å䣬ÕâÊÇÒ»¸ö´íÎó¡£ ¸üÏêϸµÄÐÅÏ¢²Î¼û"E. È·¶¨ÐÍÄÚÈÝÄ£ÐÍ".

ÓÐЧÐÔÔ¼Êø: ÑϸñµÄ×é/PEǶÌ×
²ÎÊýʵÌåµÄÖû»Îı¾ÓÃÀ¨ºÅÀ¨ÆðµÄ×éÑϸñǶÌס£¼´£¬Èç¹ûchoice£¬seq»òMixedÓï·¨³É·ÖµÄ¿ªÊ¼»ò½áÊøÀ¨ºÅ³öÏÖÔÚij¸ö²ÎÊýʵÌåµÄÖû»Îı¾ÖУ¬Á½Õß±ØÐëͬÔÚ´ËÖû»Îı¾ÖС£³öÓÚ»¥²Ù×÷ÐÔ¿¼ÂÇ£¬Èç¹ûÒ»¸ö²ÎÊýʵÌåÒýÓóöÏÖÔÚchoice£¬seq»òMixedÓï·¨³É·ÖÖÐʱ£¬ËüµÄÖû»Îı¾²»Ó¦Îª¿Õ£¬Í¬Ê±ÆäÖû»Îı¾µÄµÚÒ»¸öºÍ×îºóÒ»¸ö·Ç¿Õ×Ö·û²»Ó¦ÎªÒ»¸öÁ¬½Ó·û(|»ò,)¡£

ÔªËØÐÍÄÚÈݵÄÄ£Ð;ÙÀý£º

<!ELEMENT spec (front, body, back?)>
<!ELEMENT div1 (head, (p | list | note)*, div2*)>
<!ELEMENT dictionary-body (%div.mix; | %dict.mix;)*>

3.2.2 »ìºÏÐÍÄÚÈÝ(Mixed Content)

µ±Ä³ÔªËØÀàÐÍ¿ÉÒÔ°üº¬×Ö·ûÊý¾Ý£¬Æä¼ä¿ÉÒÔËæÒâ´©²å×ÓÔªËØʱ£¬³Æ´ËÔªËØÀàÐ;ßÓлìºÏÐÍÄÚÈÝ¡£ÔÚÕâÖÖÇé¿öÏ£¬¶Ô×ÓÔªËصÄÀàÐÍ¿ÉÄÜÓÐËùÏÞÖÆ£¬µ«¶ÔËüÃǵĴÎÐòºÍ³öÏÖ´ÎÊýûÓÐÏÞÖÆ£º

»ìºÏÐÍÄÚÈÝÉùÃ÷
[51]  Mixed ::= '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*'
¡¡ ¡¡ ¡¡ | '(' S? '#PCDATA' S? ')' [ VC: ÑϸñµÄ×é/PEǶÌ× ]
¡¡ ¡¡ ¡¡ ¡¡ [ VC: ÎÞÖظ´ÀàÐÍ ]

ÆäÖÐName¸ø³öÁË×ÓÔªËصÄÔªËصÄÀàÐÍ¡£

ÓÐЧÐÔÔ¼Êø: ÎÞÖظ´ÀàÐÍ
ͬһÃû×ÖÔÚµ¥¸ö»ìºÏÐÍÄÚÈÝÉùÃ÷ÖÐÖ»ÄܳöÏÖÒ»´Î¡£

»ìºÏÄÚÈÝÉùÃ÷µÄÀý×Ó£º

<!ELEMENT p (#PCDATA|a|ul|b|i|em)*>
<!ELEMENT p (#PCDATA | %font; | %phrase; | %special; | %form;)* >
<!ELEMENT b (#PCDATA)>

3.3 ÊôÐÔ±íÉùÃ÷

ÊôÐÔÓÃÓÚ¹ØÁªÃû×Ö-Öµ¶ÔºÍÔªËØ¡£ÊôÐÔֵ˵Ã÷Ö»ÄÜÔÚÆðʼ±êÇ©ºÍ¿ÕÔªËرêÇ©ÖгöÏÖ; Òò´Ë£¬ÓÃÓÚʶ±ðËüÃǵIJúÉúʽ³öÏÖÔÚ"3.1 Æðʼ±êÇ©£¬½áÊø±êÇ©ºÍ¿ÕÔªËرêÇ©"ÖС£ÊôÐÔ±íÉùÃ÷¿ÉÒÔÓÃÓÚ£º

ÊôÐÔ±íÉùÃ÷ Ïêϸ˵Ã÷ÁËÓë¸ø¶¨ÔªËØÀàÐÍÏà¹ØÁªµÄÿһ¸öÊôÐÔµÄÃû×Ö£¬Êý¾ÝÀàÐͺÍȱʡֵ(Èç¹ûÓеĻ°)£º

ÊôÐÔ±íÉùÃ÷
[52]  AttlistDecl ::= '<!ATTLIST' S Name AttDef* S? '>'
[53]  AttDef ::= S Name S AttType S DefaultDecl

AttlistDecl¹æÔòÖÐNameÊÇÔªËصÄÀàÐÍ¡£ÓÉÓû§Ñ¡Ôñ£¬µ±ÊôÐÔÉùÃ÷Ïà¹ØµÄÔªËØÀàÐÍûÓб»ÉùÃ÷ʱ£¬XML´¦ÀíÆ÷¿ÉÒÔ¸ø³öÒ»¸ö¾¯¸æ£¬µ«Õâ²»ÊÇÒ»¸ö´íÎó¡£AttDef¹æÔòÖеÄNameÊÇÊôÐÔµÄÃû×Ö¡£

µ±Óëij¸ö¸ø¶¨ÔªËØÀàÐÍÏà¹ØµÄAttlistDecl³¬¹ýÒ»¸öʱ£¬ÕâЩÉùÃ÷ÖеÄÄÚÈݱ»ºÏ²¢ÔÚÒ»Æð¡£µ±¸ø¶¨ÔªËØÀàÐ͵Äij¸öÊôÐԵĶ¨Ò峬¹ýÒ»¸öʱ£¬°ó¶¨µÚÒ»¸ö¶¨Ò壬ÆäÓඨÒå±»ºöÂÔ¡£³öÓÚ»¥²Ù×÷ÐÔ¿¼ÂÇ£¬DTDµÄ×÷Õß¿ÉÒÔÑ¡ÔñÒ»¸ö¸ø¶¨µÄÔªËØÀàÐÍÖÁ¶àÓÐÒ»¸öÊôÐÔ±íÉùÃ÷£¬Ò»¸ö¸ø¶¨µÄÊôÐÔÃûÖÁ¶àÓÐÒ»¸öÊôÐÔ¶¨Ò壬ÒÔ¼°Ã¿¸öÊôÐÔ±íÉùÃ÷ÖÁÉÙÓÐÒ»¸öÊôÐÔ¶¨Òå¡£³öÓÚ»¥²Ù×÷ÐÔ¿¼ÂÇ£¬µ±Ò»¸ö¸ø¶¨ÔªËØÓг¬¹ýÒ»¸öµÄÊôÐÔ±íÉùÃ÷»òÒ»¸ö¸ø¶¨ÊôÐÔÓг¬¹ýÒ»¸öµÄÊôÐÔ¶¨Òåʱ£¬XML´¦ÀíÆ÷¿ÉÒÔ£¬ÓÉÓû§Ñ¡Ôñ£¬¸ø³ö¾¯¸æ£¬µ«Õâ²»ÊÇÒ»¸ö´íÎó¡£

3.3.1 ÊôÐÔÀàÐÍ

XMLÊôÐÔÓÐÈýÖÖÀàÐÍ£º×Ö·û´®ÀàÐÍ£¬Ò»×é¼ÇºÅ»¯ÀàÐͺÍö¾ÙÀàÐÍ¡£×Ö·û´®ÀàÐÍ¿ÉÒÔÒÔÈÎÒâ³£Á¿×Ö·û´®ÎªÖµ; ¸÷¸ö¼ÇºÅ»¯ÀàÐÍÓв»Í¬µÄ´Ê·¨ºÍÓïÒåÔ¼Êø£¬ÈçÏ£º

ÊôÐÔÀàÐÍ
[54]  AttType ::= StringTypeTokenizedTypeEnumeratedType
[55]  StringType ::= 'CDATA'
[56]  TokenizedType ::= 'ID' [ VC: ID ]
¡¡ ¡¡ ¡¡ ¡¡ [ VC: ÿÖÖÔªËØÀàÐÍÒ»¸öID ]
¡¡ ¡¡ ¡¡ ¡¡ [ VC: IDÊôÐÔµÄȱʡֵ ]
¡¡ ¡¡ ¡¡ | 'IDREF' [ VC: IDREF ]
¡¡ ¡¡ ¡¡ | 'IDREFS' [ VC: IDREF ]
¡¡ ¡¡ ¡¡ | 'ENTITY' [ VC: ʵÌåÃû ]
¡¡ ¡¡ ¡¡ | 'ENTITIES' [ VC: ʵÌåÃû ]
¡¡ ¡¡ ¡¡ | 'NMTOKEN' [ VC: Ãû×ּǺŠ]
¡¡ ¡¡ ¡¡ | 'NMTOKENS' [ VC: Ãû×ּǺŠ]

ÓÐЧÐÔÔ¼Êø: ID
IDÀàÐ͵ÄÖµ±ØÐëÆ¥ÅäName²úÉúʽ¡£×÷Ϊ´ËÀàÐÍÖµµÄÃû×ÖÖ»ÄÜÔÚXMLÎļþÖгöÏÖÒ»´Î;¼´£¬IDÀàÐ͵ÄÖµ±ØÐëÄÜΨһ±êʶԪËØ¡£

ÓÐЧÐÔÔ¼Êø: ÿÖÖÊôÐÔÀàÐÍÒ»¸öID
ÿÖÖÊôÐÔÀàÐÍÖ»ÄÜÓÐÒ»¸öIDÊôÐÔ¡£

ÓÐЧÐÔÔ¼Êø: IDÊôÐÔµÄȱʡֵ
IDÊôÐÔ±ØÐëÓÐÒ»¸öÉùÃ÷Ϊ#IMPLIED»ò#REQUIREDµÄȱʡֵ¡£

ÓÐЧÐÔÔ¼Êø: IDREF
IDREFÀàÐ͵ÄÖµ±ØÐëÆ¥ÅäName²úÉúʽ£¬IDREFSÀàÐ͵ÄÖµ±ØÐëÆ¥ÅäNames²úÉúʽ£»Ã¿Ò»¸öName±ØÐëÆ¥ÅäXMLÎļþÖÐijЩԪËØIDÊôÐÔµÄÖµ£»Ò²¾ÍÊÇ˵£¬IDREFÀàÐ͵ÄÖµ±ØÐëÆ¥ÅäijЩIDÊôÐÔµÄÖµ¡£

ÓÐЧÐÔÔ¼Êø: ʵÌåÃû
ENTITYÀàÐ͵ÄÖµ±ØÐëÆ¥ÅäName²úÉúʽ£¬ENTITIESÀàÐ͵ÄÖµ±ØÐëÆ¥ÅäNames²úÉúʽ£» ÿһ¸öName±ØÐëÆ¥ÅäDTDÖÐÉùÃ÷µÄδÎöʵÌåµÄÃû×Ö¡£

ÓÐЧÐÔÔ¼Êø: Ãû×ּǺÅ
NMTOKENÀàÐ͵ÄÖµ±ØÐëÆ¥ÅäNmtoken²úÉúʽ;NMTOKENSÀàÐ͵ÄÖµ±ØÐëÆ¥ÅäNmtokens²úÉúʽ¡£

ö¾ÙÀàÐ͵ÄÊôÐÔ¿ÉÒÔÔÚÉùÃ÷ÖÐÌṩµÄÈ¡Öµ±íÖÐÈ¡Öµ¡£ÓÐÁ½ÖÖö¾ÙÀàÐÍ£º

ö¾ÙÊôÐÔÀàÐÍ
[57]  EnumeratedType ::= NotationTypeEnumeration
[58]  NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')' [ VC: ¼Ç·¨ÊôÐÔ ]
[59]  Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')' [ VC: ö¾Ù ]

Ò»¸öNOTATIONÀàÐ͵ÄÊôÐÔ±êʶÁËÒ»ÖÖÓÃÓÚ½âÊÍÓë´ËÊôÐÔÏà¹ØµÄÔªËصļǷ¨£¬´Ë¼Ç·¨ÖÐÓÃϵͳ»ò¹«¹²±êʶ·ûÔÚDTDÖÐÉùÃ÷¡£

ÓÐЧÐÔÔ¼Êø: ¼Ç·¨ÊôÐÔ
´ËÀàÐ͵ÄÖµ±ØÐëÓëÉùÃ÷ÖÐËù°üº¬µÄ¼Ç·¨ÃûÖ®Ò»ÏàÆ¥Åä;ÉùÃ÷ÖеÄËùÓмǷ¨Ãû¶¼±ØÐëÉùÃ÷¡£

ÓÐЧÐÔÔ¼Êø: ö¾Ù
´ËÀàÐ͵ÄÖµ±ØÐëÓëÉùÃ÷ÖÐËù°üº¬µÄNmtoken¼ÇºÅÖ®Ò»ÏàÆ¥Åä¡£

³öÓÚ»¥²Ù×÷ÐÔ¿¼ÂÇ£¬Í¬Ò»NmtokenÖ»ÄÜÔÚµ¥¸öÔªËØÀàÐ͵Äö¾ÙÊôÐÔÀàÐÍÖгöÏÖÒ»´Î¡£

3.3.2 ÊôÐÔȱʡֵ

ÊôÐÔÉùÃ÷ÌṩµÄÐÅÏ¢Ö¸Ã÷ÁËijÊôÐÔÊÇ·ñ±ØÐë³öÏÖ£¬Í¬Ê±Ö¸Ã÷ÁËÔÚ±»ÉùÃ÷µÄÊôÐÔ²»ÊDZØÐë³öÏÖ¶øÎļþÖÐûÓгöÏÖ´ËÊôÐÔµÄÇé¿öÏ£¬XML´¦ÀíÆ÷Ó¦ÈçºÎ´¦Àí¡£

ÊôÐÔȱʡֵ
[60]  DefaultDecl ::= '#REQUIRED' | '#IMPLIED'
¡¡ ¡¡ ¡¡ | (('#FIXED' S)? AttValue) [ VC: ±ØÐëµÄÊôÐÔ ]
¡¡ ¡¡ ¡¡ ¡¡ [ VC: ºÏ·¨µÄÊôÐÔȱʡֵ ]
¡¡ ¡¡ ¡¡ ¡¡ [ WFC: ÔÚÊôÐÔÖµÖÐÎÞ< ]
¡¡ ¡¡ ¡¡ ¡¡ [ VC: ¹Ì¶¨µÄÊôÐÔȱʡֵ ]

ÔÚÒ»¸öÊôÐÔÉùÃ÷ÖУ¬#REQUIRED±íʾ±ØÐë×ÜÊÇÌṩ´ËÊôÐÔ£¬#IMPLIED±íʾ²»Ìṩȱʡֵ¡£Èç¹ûÉùÃ÷¼È²»ÊÇ#REQUIRED£¬Ò²²»ÊÇ#IMPLIED£¬ÄÇôAttValueÖµ°üº¬ÁËËùÉùÃ÷µÄȱʡֵ;¹Ø¼ü×Ö#FIXED¹æ¶¨´ËÊôÐÔ±ØÐë×ÜÊÇÓÐȱʡֵ¡£Èç¹ûÉùÃ÷ÁËÒ»¸öȱʡֵ£¬µ±XML´¦ÀíÆ÷Óöµ½Ò»¸ö±»Ê¡ÂÔµÄÊôÐÔʱ£¬Ëü½«µ±³É´ËÊôÐÔÒÔȱʡֵ³öÏÖ

ÓÐЧÐÔÔ¼Êø: ±ØÐëµÄÊôÐÔ
Èç¹ûȱʡֵÉùÃ÷Êǹؼü×Ö#REQUIRED£¬ÄÇôÊôÐÔ±íÉùÃ÷ËùÖ¸ÀàÐ͵ÄÔªËØÖж¼±ØÐëÓдËÊôÐÔ¡£

ÓÐЧÐÔÔ¼Êø: ºÏ·¨µÄÊôÐÔȱʡֵ
±»ÉùÃ÷µÄÊôÐÔȱʡֵ±ØÐëÂú×ã±»ÉùÃ÷µÄÊôÐÔÀàÐ͵Ĵʷ¨Ô¼Êø¡£

ÓÐЧÐÔÔ¼Êø: ¹Ì¶¨µÄÊôÐÔȱʡֵ
Èç¹ûijÊôÐÔµÄȱʡֵÓùؼü×Ö#FIXEDÉùÃ÷£¬´ËÊôÐÔµÄËùÓÐʵÀý±ØÐëÆ¥Åä¸Ãȱʡֵ¡£

ÊôÐÔ±íÉùÃ÷µÄÀý×Ó£º

<!ATTLIST termdef
          id      ID      #REQUIRED
          name    CDATA   #IMPLIED>
<!ATTLIST list
          type    (bullets|ordered|glossary)  "ordered">
<!ATTLIST form
          method  CDATA   #FIXED "POST">

3.3.3 ÊôÐÔ-Öµ¶ÔµÄ¹æ·¶»¯(Attribute-Value Normalization)

ÔÚ½«ÊôÐÔµÄÖµ´«¸øÓ¦Óûò¼ìÑéÓÐЧÐÔ֮ǰ£¬XML´¦ÀíÆ÷±ØÐ뽫Æä¹æ·¶»¯£º

Èç¹û±»ÉùÃ÷µÄÖµ²»ÊÇCDATA£¬ÄÇôXML´¦ÀíÆ÷±ØÐë¼ÌÐø´¦Àí¹æ·¶»¯ºóµÄÖµ£¬È¥µôÆäÇ°µ¼ºÍβËæ¿Õ¸ñ(#x20)×Ö·û£¬²¢½«¿Õ¸ñ(#x20)×Ö·ûÐòÁÐÌæ»»³Éµ¥¸ö¿Õ¸ñ(#x20)×Ö·û¡£

²»½øÐÐÑéÖ¤µÄÓï·¨·ÖÎöÆ÷Ó¦¸Ã½«ËùÓÐÉÐδ¶Áµ½ÉùÃ÷²¿·ÖµÄÊôÐÔµ±³É±»ÉùÃ÷ΪCDATA¡£

3.4 Ìõ¼þ¶Î(Conditional Sections)

Ìõ¼þ¶ÎÊÇÎļþÀàÐÍÉùÃ÷Íⲿ×Ó¼¯µÄÒ»²¿·Ö£¬È¡¾öÓÚÏàÓ¦µÄ¹Ø¼ü×Ö£¬ËüÃÇ»ò±»°üº¬ÔÚDTDÂß¼­½á¹¹Ö®ÄÚ£¬»ò±»ÅųýÔÚDTDÂß¼­½á¹¹Ö®Íâ¡£

Ìõ¼þ¶Î
[61]  conditionalSect ::= includeSectignoreSect
[62]  includeSect ::= '<![' S? 'INCLUDE' S? '[' extSubsetDecl ']]>'
[63]  ignoreSect ::= '<![' S? 'IGNORE' S? '[' ignoreSectContents* ']]>'
[64]  ignoreSectContents ::= Ignore ('<![' ignoreSectContents ']]>' Ignore)*
[65]  Ignore ::= Char* - (Char* ('<![' | ']]>') Char*)

ͬÄÚ²¿»òÍⲿDTD×Ó¼¯Ò»Ñù£¬Ìõ¼þ¶Î¿ÉÒÔ°üº¬Ò»¸ö»ò¶à¸öÍêÕûµÄÉùÃ÷£¬×¢ÊÍ£¬´¦ÀíÖ¸Á»òǶÌ×µÄÌõ¼þ¶Î£¬Æä¼ä¿ÉÒÔ¼ÐÔӿհס£

Èç¹ûÌõ¼þ¶ÎµÄ¹Ø¼ü×ÖÊÇINCLUDE£¬ÄÇôÌõ¼þ¶ÎµÄÄÚÈÝÊÇDTDµÄÒ»²¿·Ö£¬Èç¹ûÌõ¼þ¶ÎµÄ¹Ø¼ü×ÖÊÇIGNORE£¬ÄÇôÌõ¼þ¶ÎµÄÄÚÈÝÂß¼­Éϲ»ÊÇDTDµÄÒ»²¿·Ö¡£×¢Òâ¶ÔÓÚ¿É¿¿µÄÓï·¨·ÖÎö¹ý³Ì£¬ÉõÖÁ±ØÐë¶ÁÈ¡±»ºöÂÔµÄÌõ¼þ¶ÎµÄÄÚÈÝÒÔ¼ì²âǶÌ×µÄÌõ¼þ¶Î£¬±£Ö¤×îÍâ²ã(±»ºöÂÔ)µÄÌõ¼þ¶ÎµÄ½áβ±»Ç¡µ±µØ¼ì²âµ½¡£Èç¹ûÒ»¸ö¹Ø¼ü×ÖΪINCLUDEµÄÌõ¼þ¶Î³öÏÖÔÚ¸ü´óµÄ¹Ø¼ü×ÖΪIGNOREµÄÌõ¼þ¶ÎÖУ¬ÄÚÍâÁ½¸öÌõ¼þ¶Î¶¼±»ºöÂÔ¡£

Èç¹ûÌõ¼þ¶ÎµÄ¹Ø¼ü×ÖÊÇÒ»¸ö²ÎÊýʵÌåÒýÓ㬴¦ÀíÆ÷ÔÚ¾ö¶¨ÊÇ·ñ°üº¬»òºöÂÔ´ËÌõ¼þ¶ÎÇ°£¬±ØÐëÏȽ«¸Ã²ÎÊýʵÌåÖû»³ÉÆäÄÚÈÝ¡£

Ò»¸öÀý×Ó£º

<!ENTITY % draft 'INCLUDE' >
<!ENTITY % final 'IGNORE' >
 
<![%draft;[
<!ELEMENT book (comments*, title, body, supplements?)>
]]>
<![%final;[
<!ELEMENT book (title, body, supplements?)>
]]>

4. ÎïÀí½á¹¹

Ò»¸öXMLÎļþ¿ÉÄÜ°üº¬Ò»¸ö»ò¶à¸ö´æ´¢µ¥Ôª¡£ËüÃDZ»³ÆΪʵÌå(entity);ËüÃǶ¼¾ßÓÐÄÚÈݲ¢ÇÒ¶¼ÓÃÃû×Ö½øÐбêʶ(³ýÁËÎļþʵÌ壬¼ûÏ£¬ºÍÍⲿDTD×Ó¼¯Ö®Íâ)¡£Ã¿Ò»¸öXMLÎļþÓÐÒ»¸ö³ÆΪÎļþʵÌåµÄʵÌ壬Ëü×÷ΪXML´¦ÀíÆ÷´¦ÀíµÄÆðµã²¢¿ÉÄÜ°üº¬ÁËÕû¸öÎļþ¡£

ʵÌå¿ÉÒÔÊÇÒÑÎöµÄ»òδÎöµÄ¡£ÒÑÎöʵÌå(parsed entity)µÄÄÚÈݱ»³ÆΪËüµÄÖû»Îı¾;´ËÎı¾±»¿´³ÉÊÇÎļþÕûÌåµÄÒ»²¿·Ö¡£

δÎöʵÌå(unparsed entity)ÊÇÒ»ÖÖ×ÊÔ´£¬ÆäÄÚÈÝ¿ÉÒÔÊÇÒ²¿ÉÒÔ²»ÊÇÎı¾£¬²¢ÇÒ£¬Èç¹ûÊÇÎı¾µÄ»°£¬¿ÉÒÔ²»ÊÇXML¡£Ã¿Ò»¸öδÎöʵÌåÓÐÒ»¸öÏà¹ØÁªµÄÓÃÃû×Ö±êʶµÄ¼Ç·¨¡£³ýÁËÒªÇóXML´¦ÀíÆ÷ÄÜÏòÓ¦ÓÃÌṩʵÌåºÍ¼Ç·¨µÄ±êʶ·ûÖ®Í⣬XML¶ÔδÎöʵÌåµÄÄÚÈݲ»×÷ÈκÎÏÞÖÆ¡£

ÒÑÎöʵÌåÒÔʵÌåÒýÓõķ½Ê½Ê¹ÓÃÃû×ÖÀ´µ÷ÓÃ;δÎöʵÌåÓÃENTITY»òENTITIESÊôÐÔÖиø³öµÄÃû×Öµ÷Óá£

ÆÕͨʵÌå(general entity)ÊÇÄÇЩÔÚÎļþÄÚÈÝÖÐʹÓõÄʵÌå¡£ÔÚ±¾¹æ·¶ÖУ¬ÆÕͨʵÌåÓÐʱÓÃδÐÞÊεÄÊõÓïentityÀ´±íʾ¡£²ÎÊýʵÌåÊÇÓÃÓÚDTDÄÚµÄÒÑÎöʵÌå¡£ÕâÁ½ÀàʵÌåÓò»Í¬ÐÎʽµÄÒýÓã¬ÔÚ²»Í¬µÄÉÏÏÂÎÄÖÐʶ±ð¡£ÁíÍ⣬ËüÃÇʹÓò»Í¬µÄÃû×Ö¿Õ¼ä;¾ßÓÐÏàͬÃû×ֵIJÎÊýʵÌåºÍÆÕͨʵÌåÊÇÁ½¸ö½ØÈ»²»Í¬µÄÁ½¸öʵÌå¡£

4.1 ×Ö·ûºÍʵÌåÒýÓÃ(Character and Entity References)

Ò»¸ö×Ö·ûÒýÓÃÒýÓÃISO/IEC 10646×Ö·û¼¯ÖеÄÒ»¸ö×Ö·û¡£ÀýÈç²»ÄÜÓÃÊäÈëÉ豸ֱ½ÓÊäÈëµÄ×Ö·û¡£

×Ö·ûÒýÓÃ
[66]  CharRef ::= '&#' [0-9]+ ';'
¡¡ ¡¡ ¡¡ | '&#x' [0-9a-fA-F]+ ';' [ WFC: ºÏ·¨×Ö·û ]

¹æ·¶ÐÔÔ¼Êø: ºÏ·¨×Ö·û
ÓÃ×Ö·ûÒýÓÃÒýÓõÄ×Ö·û±ØÐëÆ¥ÅäChar²úÉúʽ¡£

Èç¹û×Ö·ûÒýÓÃÒÔ"&#x"¿ªÍ·£¬Ö±µ½ÖÕ½á;µÄÊý×ÖºÍ×ÖĸÌṩÁËij×Ö·ûÔÚISO/IEC 10646ÖдúÂëµÄÒ»¸öÊ®Áù½øÖƱíʾ¡£Èç¹ûËü½öÒÔ"&#"¿ªÍ·£¬Ö±µ½ÖÕ½á;µÄÊý×ÖÌṩÁËij×Ö·ûµÄ´úÂëµÄÊ®½øÖµ±íʾ¡£

ʵÌåÒýÓÃ(entity reference)ÒýÓÃÒ»¸öÃüÃûʵÌåµÄÄÚÈÝ¡£¶ÔÒÑÎöÆÕͨʵÌåµÄÒýÓÃʹÓÃ"and"ºÅ(&)ºÍ·ÖºÅ(;)×÷Ϊ¶¨½ç·û¡£²ÎÊýʵÌåÒýÓÃÔòʹÓðٷֺÅ(%)ºÍ·ÖºÅ(;)×÷Ϊ¶¨½ç·û¡£

ʵÌåÒýÓÃ
[67]  Reference ::= EntityRefCharRef
[68]  EntityRef ::= '&' Name ';' [ WFC: ÉùÃ÷ʵÌå ]
¡¡ ¡¡ ¡¡ ¡¡ [ VC: ÉùÃ÷ʵÌå ]
¡¡ ¡¡ ¡¡ ¡¡ [ WFC: ÒÑÎöʵÌå ]
¡¡ ¡¡ ¡¡ ¡¡ [ WFC: Î޵ݹé ]
[69]  PEReference ::= '%' Name ';' [ VC: ÉùÃ÷ʵÌå ]
¡¡ ¡¡ ¡¡ ¡¡ [ WFC: Î޵ݹé ]
¡¡ ¡¡ ¡¡ ¡¡ [ WFC: ÔÚDTDÄÚ ]

¹æ·¶ÐÔÔ¼Êø: ÉùÃ÷ʵÌå
ÔÚÒ»¸öûÓÐÈκÎDTDµÄÎļþ£¬»òÒ»¸öÖ»Óв»°üº¬²ÎÊýʵÌåÒýÓõÄÄÚ²¿DTD×Ó¼¯µÄÎļþ£¬»òÒ»¸ö"standalone='yes'"µÄÎļþÄÚ£¬ÔÚʵÌåÒýÓÃÖиø³öµÄName±ØÐëÓëʵÌåÉùÃ÷ÖÐËù¸ø³öµÄÏàÆ¥Å䣬µ«¹æ·¶µÄÎļþ²»ÐèÒªÉùÃ÷ÒÔϵÄÕâЩʵÌ壺amp£¬lt£¬gt£¬aposºÍquot¡£²ÎÊýʵÌåµÄÉùÃ÷±ØÐëÏÈÓÚÈκζÔËüµÄÒýÓá£ÀàËƵأ¬ÆÕͨʵÌåµÄÉùÃ÷±ØÐëÏÈÓÚÈκÎÔÚÊôÐÔ±íÉùÃ÷ÖеÄȱʡֵÖгöÏֵĶÔËüµÄÒýÓá£×¢Òâ¶ÔÓÚÔÚÍⲿ×Ó¼¯»òÍⲿ²ÎÊýʵÌåÖÐÉùÃ÷µÄʵÌ壬²»½øÐÐÑéÖ¤µÄ´¦ÀíÆ÷²»±ØÒª¶ÁÈ¡ºÍ´¦ÀíËüÃǵÄÉùÃ÷;¶ÔÕâЩÎļþ£¬½öµ±standalone='yes'ʱ£¬ÊµÌå±ØÐë±»ÉùÃ÷µÄ¹æÔò²ÅÊÇÒ»¸ö¹æ·¶ÐÔÔ¼Êø¡£

ÓÐЧÐÔÔ¼Êø: ÉùÃ÷ʵÌå
ÔÚÒ»¸öÓÐÍⲿ×Ó¼¯»òÍⲿ²ÎÊýʵÌåÇÒ"standalone='no'"µÄʵÌåÖУ¬ÊµÌåÒýÓÃÖиø³öµÄName±ØÐëÓëʵÌåÉùÃ÷ÖÐËù¸ø³öµÄÏàÆ¥Åä¡£³öÓÚ»¥²Ù×÷ÐÔ¿¼ÂÇ£¬ÓÐЧµÄÎļþÓ¦¸ÃÒÔ"4.6 Ô¤¶¨ÒåʵÌå"Öеļò»¯ÐÎʽÉùÃ÷ʵÌåamp£¬lt£¬gt£¬aposºÍquot¡£²ÎÊýʵÌåµÄÉùÃ÷±ØÐëÏÈÓÚÈκζÔËüµÄÒýÓá£ÀàËƵأ¬ÆÕͨʵÌåµÄÉùÃ÷±ØÐëÏÈÓÚÈκÎÔÚÊôÐÔ±íÉùÃ÷ÖеÄȱʡֵÖгöÏֵĶÔËüµÄÒýÓá£

¹æ·¶ÐÔÔ¼Êø: ÒÑÎöʵÌå
ʵÌåÒýÓò»ÄÜ°üº¬Ò»¸öδÎöʵÌåµÄÃû×Ö¡£Î´ÎöʵÌåÖ»ÄÜÔÚÉùÃ÷ΪENTITY»òENTITIESµÄÊôÐÔÖµÖÐÒýÓá£

¹æ·¶ÐÔÔ¼Êø: Î޵ݹé
ÒÑÎöʵÌå²»ÄÜÖ±½Ó»ò¼ä½ÓµØ°üº¬¶Ô×ÔÉíµÄµÝ¹éÒýÓá£

¹æ·¶ÐÔÔ¼Êø: ÔÚDTDÄÚ
²ÎÊýʵÌåÒýÓÃÖ»ÄÜÔÚDTDÖгöÏÖ¡£

×Ö·ûÒýÓúÍʵÌåÒýÓõÄÀý×Ó£º

Type <key>less-than</key> (&#x3C;) to save options.
This document was prepared on &docdate; and
is classified &security-level;.

²ÎÊýʵÌåÒýÓõÄÀý×Ó£º

<!-- declare the parameter entity "ISOLat2"... -->
<!ENTITY % ISOLat2
         SYSTEM "http://www.xml.com/iso/isolat2-xml.entities" >
<!-- ... now reference it. -->
%ISOLat2;

4.2 ʵÌåÉùÃ÷(Entity Declaration)

ʵÌåÒÔÈçÏ·½Ê½ÉùÃ÷£º

ʵÌåÉùÃ÷
[70]  EntityDecl ::= GEDeclPEDecl
[71]  GEDecl ::= '<!ENTITY' S Name S EntityDef S? '>'
[72]  PEDecl ::= '<!ENTITY' S '%' S Name S PEDef S? '>'
[73]  EntityDef ::= EntityValue | (ExternalID NDataDecl?)
[74]  PEDef ::= EntityValueExternalID

ʵÌåÒýÓÃÖеÄName±êʶÁ˸ÃʵÌå;¶ÔÓÚδÎöʵÌ壬ENTITY»òENTITIESÊôÐÔµÄÖµ±êʶÁ˸ÃʵÌå¡£Èç¹ûͬһʵÌå±»ÉùÃ÷Á˲»Ö¹Ò»´Î£¬°ó¶¨µÚÒ»¸öÓöµ½µÄÉùÃ÷¡£ÓÉÓû§Ñ¡Ôñ£¬Èç¹ûʵÌå±»¶à´ÎÉùÃ÷£¬XML´¦ÀíÆ÷¿ÉÒÔ¸ø³ö¾¯¸æ¡£

4.2.1 ÄÚ²¿ÊµÌå(Internal Entities)

Èç¹ûʵÌ嶨ÒåÊÇÒ»¸öEntityValue£¬±»¶¨ÒåµÄʵÌå±»³ÆΪÄÚ²¿ÊµÌå¡£ÄÚ²¿ÊµÌåûÓе¥¶ÀµÄÎïÀí´æ´¢¶ÔÏó£¬ÊµÌåµÄÄÚÈÝÔÚÉùÃ÷Öиø³ö¡£×¢Òâ³£Á¿ÊµÌåÖµÖÐһЩʵÌåºÍ×Ö·ûÒýÓõĴ¦Àí¿ÉÄÜÒªÇó²úÉúÕýÈ·µÄÖû»Îı¾£º²Î¼û"4.5 ÄÚ²¿Öû»Îı¾µÄ¹¹Ôì"¡£

ÄÚ²¿ÊµÌåÊÇÒÑÎöʵÌå¡£

ÄÚ²¿ÊµÌåÉùÃ÷µÄÀý×Ó£º

<!ENTITY Pub-Status "This is a pre-release of the
 specification.">

4.2.2 ÍⲿʵÌå(External Entities)

Èç¹ûʵÌå²»ÊÇÄÚ²¿µÄ£¬ÄÇôËüÊÇÒ»¸öÍⲿʵÌ壬ÉùÃ÷ÈçÏ£º

ÍⲿʵÌåÉùÃ÷
[75]  ExternalID ::= 'SYSTEM' S SystemLiteral
¡¡ ¡¡ ¡¡ | 'PUBLIC' S PubidLiteral S SystemLiteral
[76]  NDataDecl ::= S 'NDATA' S Name [ VC: ÉùÃ÷¼Ç·¨ ]

Èç¹ûÓÐNDataDecl£¬ÄÇôÕâÊÇÒ»¸öÆÕͨδÎöʵÌå;·ñÔòËüÊÇÒ»¸öÒÑÎöʵÌå¡£

ÓÐЧÐÔÔ¼Êø: ÉùÃ÷¼Ç·¨
Name±ØÐëÓë¼Ç·¨µÄÃû×ÖÏàÆ¥Åä¡£

SystemLiteral±»³ÆΪ¸ÃʵÌåµÄϵͳ±êʶ·û¡£ÕâÊÇÒ»¸öURI£¬¿ÉÒÔÓÃÓÚ´æÈ¡´ËʵÌå¡£×¢Òâ¾®ºÅ(#)ºÍURIÖг£ÓõÄƬ¶Ï±êʶ·ûÐÎʽÉ϶øÑÔ²»ÊÇURIµÄÒ»²¿·Ö£»Èç¹ûÒ»¸öƬ¶Ï±êʶ·û×÷Ϊϵͳ±êʶ·ûµÄ²¿·Ö¸ø³ö£¬XML´¦ÀíÆ÷¿ÉÒÔ¸ø³öÒ»¸ö´íÎó¡£³ý·ÇÔÚ±¾¹æ·¶·¶Î§Ö®ÍâÁíÍâ¸ø³ö(È磬һ¸öÌØÊâDTDÖж¨ÒåµÄרÓÃXMLÔªËØÀàÐÍ£¬»òÒ»¸öÌØÊâÓ¦Óù淶Öж¨ÒåµÄ´¦ÀíÖ¸Áî)£¬Ïà¶ÔURIÖ¸Ïà¶ÔÓÚʵÌåÉùÃ÷ËùÔÚ×ÊÔ´µÄλÖá£Òò´Ë£¬Ò»¸öURI¿ÉÄÜÊÇÏà¶ÔÓÚÎļþʵÌ壬»òÏà¶ÔÓÚ°üº¬ÍⲿDTD×Ó¼¯µÄʵÌ壬»òÏà¶ÔÓÚÆäËûһЩÍⲿ²ÎÊýʵÌå¡£

XML´¦ÀíÆ÷´¦ÀíURIÖеķÇASCII×Ö·ûʱ£¬Ó¦¸Ã½«UTF-8ÖеÄ×Ö·ûÓÃÒ»¸ö»ò¶à¸ö×Ö½Ú±íʾ£¬È»ºó½«ÕâЩ×Ö·ûÓÃURIתÒå»úÖÆתÒå(¼´£¬½«Ã¿¸ö×Ö½Úת»»³É%HH£¬ÆäÖÐHHÊÇ×Ö½ÚÖµµÄÊ®Áù½øÖƼǷ¨)¡£

³ýÁËϵͳ±êʶ·ûÖ®Í⣬Íⲿ±êʶ·û»¹¿ÉÒÔ°üº¬¹«¹²±êʶ·û¡£ÊÔͼ´æȡʵÌåÄÚÈݵÄXML´¦ÀíÆ÷¿ÉÒÔÓù«¹²±êʶ·ûÊÔ×ŲúÉúÒ»¸ö¿ÉÑ¡URI¡£Èç¹û´¦ÀíÆ÷ÎÞ·¨×öµ½ÕâÒ»µã£¬Ëü±ØÐëʹÓÃϵͳ³£Á¿ÖеÄURI¡£ÔÚÊÔ×ÅÆ¥Åä֮ǰ£¬¹«¹²±êʶ·ûÖÐËùÓпհ××Ö·û´®±ØÐë±»¹æ·¶Îªµ¥¸ö¿Õ¸ñ×Ö·û(#x20)£¬Í¬Ê±±ØÐëÈ¥µôÇ°µ¼ºÍβËæ¿Õ°×¡£

ÍⲿʵÌåÉùÃ÷µÄÀý×Ó£º

<!ENTITY open-hatch
         SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml">
<!ENTITY open-hatch
         PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN"
         "http://www.textuality.com/boilerplate/OpenHatch.xml">
<!ENTITY hatch-pic
         SYSTEM "../grafix/OpenHatch.gif"
         NDATA gif >

4.3 ÒÑÎöʵÌå(Parsed Entities)

4.3.1 Îı¾ÉùÃ÷(Text Declaration)

ÿ¸öÍⲿÒÑÎöʵÌå¿ÉÒÔÒÔÎı¾ÉùÃ÷×÷Ϊ¿ªÊ¼¡£

Îı¾ÉùÃ÷
[77]  TextDecl ::= '<?xml' VersionInfo? EncodingDecl S? '?>'

Îı¾ÉùÃ÷±ØÐëÒÔ³£Á¿ÐÎʽ¸ø³ö£¬¶ø²»ÄÜʹÓÃÒÑÎöʵÌåµÄÒýÓá£Îı¾ÉùÃ÷Ö»ÄÜÔÚÍⲿÒÑÎöʵÌåµÄ¿ªÍ·³öÏÖ£¬²»ÔÊÐíÔÚÆäËûÈκεط½³öÏÖ¡£

4.3.2 ¹æ·¶µÄÒÑÎöʵÌå(Well-Formed Parsed Entities)

Èç¹ûÎļþʵÌåÆ¥Åädocument²úÉúʽ£¬ÄÇôËüÊǹ淶µÄ¡£Èç¹ûÍⲿÆÕͨÒÑÎöʵÌåÆ¥ÅäextParsedEnt²úÉúʽ£¬ÄÇôËüÊǹ淶µÄ¡£Èç¹ûÍⲿ²ÎÊýʵÌåÆ¥ÅäextPE²úÉúʽ£¬ÄÇôËüÊǹ淶µÄ¡£

¹æ·¶µÄÍⲿÒÑÎöʵÌå
[78]  extParsedEnt ::= TextDecl? content
[79]  extPE ::= TextDecl? extSubsetDecl

Èç¹ûÄÚ²¿ÆÕͨÒÑÎöʵÌåµÄÖû»Îı¾Æ¥Åäcontent²úÉúʽ£¬ÄÇôËüÊǹ淶µÄ¡£¸ù¾Ý¶¨Ò壬ËùÓÐÄÚ²¿µÄ²ÎÊýʵÌ嶼Êǹ淶µÄ¡£

ʵÌå·ûºÏ¹æ·¶ÐÔµÄÒ»¸ö½á¹ûÊÇXMLÎļþµÄÂß¼­ºÍÎïÀí½á¹¹ÊÇÑϸñǶÌ×µÄ;Æðʼ±êÇ©£¬½áÊø±êÇ©£¬¿ÕÔªËرêÇ©£¬ÔªËØ£¬×¢ÊÍ£¬´¦ÀíÖ¸Á×Ö·ûÒýÓ㬻òʵÌåÒýÓö¼²»ÄÜÔÚÒ»¸öʵÌåÖпªÊ¼¶øÔÚÁíÒ»¸öʵÌåÖнáÊø¡£

4.3.3 ʵÌåÖеÄ×Ö·û±àÂë(Character Encoding in Entities)

XMLÎļþÖеÄÿ¸öÍⲿÒÑÎöʵÌ嶼¿ÉÒÔ¶ÔÆä×Ö·û²ÉÓÃÒ»ÖÖ²»Í¬µÄ±àÂë·½°¸¡£ËùÓÐXML´¦ÀíÆ÷±ØÐëÄܶÁ±àÂëΪUTF-8»òUTF-16µÄʵÌå¡£

ÒÔUTF-16±àÂëµÄʵÌå±ØÐëÒÔISO/IEC 10646Ôö²¹EºÍUnicode¸½Â¼B(Áã¿í¶È²»¼ä¶Ï¿Õ¸ñ×Ö·û£¬#xFEFF)ÖÐËùÃèÊöµÄ×Ö½Ú´ÎÐò±ê¼Ç(Byte Order Mark)¿ªÍ·¡£ÕâÊÇÒ»¸ö±àÂëÇ©Ãû£¬¼´²»ÊÇXMLÎļþÖбê¼ÇµÄÒ»²¿·Ö£¬Ò²²»ÊÇXMLÎļþ×Ö·ûÊý¾ÝµÄÒ»²¿·Ö¡£XML´¦ÀíÆ÷±ØÐëÄÜÓôË×Ö·ûÇø·ÖUTF-8±àÂëºÍUTF-16±àÂëµÄÎļþ¡£

ËäÈ»XML´¦ÀíÆ÷Ö»±»ÒªÇóÄܶÁÈ¡UTF-8ºÍUTF-16±àÂëµÄʵÌ壬ÒÑÓй²Ê¶ÈÏΪÊÀ½çÉÏ»¹ÓÐÆäËûµÄ±àÂë·½°¸¡£ÓÐʱ¿ÉÄÜÏëÈÃXML´¦ÀíÆ÷¶ÁÈ¡ÒÔÄÇЩ±àÂë·½°¸±àÂëµÄʵÌå¡£ÒÔ²»Í¬ÓëUTF-8ºÍUTF-16µÄ±àÂë·½°¸´æ´¢µÄʵÌå±ØÐëÒÔ°üº¬±àÂëÉùÃ÷µÄÎı¾ÉùÃ÷¿ªÍ·£º

±àÂëÉùÃ÷
[80]  EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' |  "'" EncName "'" )
[81]  EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')* /* ±àÂë·½°¸µÄÃû×ÖÖ»°üº¬À­¶¡×Öĸ */

ÔÚÎļþʵÌåÖУ¬±àÂëÉùÃ÷ÊÇXMLÉùÃ÷µÄÒ»²¿·Ö¡£EncNameÊÇËùÓñàÂë·½°¸µÄÃû×Ö¡£

ÔÚÒ»¸ö±àÂëÉùÃ÷ÖУ¬Öµ"UTF-8"£¬"UTF-16"£¬"ISO-10646-UCS-2"ºÍ"ISO-10646-UCS-4"Ó¦¸ÃÓÃÓÚ±íʾUnicode»òISO/IEC 10646Öеĸ÷ÖÖ²»Í¬±àÂëºÍ±ä»»·½°¸£¬Öµ"ISO-8859-1"£¬"ISO-8859-2"£¬... "ISO-8859-9"Ó¦¸ÃÓÃÓÚ±íʾISO 8859µÄ¸÷¸ö²¿·Ö£¬¶øÖµ"ISO-2022-JP"£¬"Shift_JIS"ºÍ"EUC-JP"Ó¦¸ÃÓÃÓÚ±íʾJIS X-0208-1997µÄ¸÷ÖÖ±àÂë¡£XML´¦ÀíÆ÷¿ÉÒÔʶ±ðÆäËû±àÂë·½°¸;½¨Òé¶ÔÓÚÔÚInternet Assigned Numbers Authority [IANA]×¢²áµÄ×Ö·û±àÂë·½°¸(ÒÔ×Ö·û¼¯(charset)µÄ·½Ê½)£¬³ýÁËÒÔÉÏËùÁеÄÖ®Í⣬ÒýÓÃʱӦʹÓÃÆä×¢²áÃû¡£×¢ÒâÕâЩע²áÃû¶¨ÒåΪ´óСдÃô¸Ð£¬Òò´ËÓûÓë֮ƥÅäµÄ´¦ÀíÆ÷ÒªÒÔ´óСдÃô¸ÐµÄ·½Ê½½øÐÐÆ¥Åä¡£

ÔÚȱÉÙÍⲿ´«ÊäЭÒé(ÈçHTTP»òMIME)ËùÌṩµÄÐÅϢʱ£¬ÒÔÏÂÇé¿ö¾ùÊÇ´íÎó£ºXML´¦ÀíÆ÷½ÓÊÕµ½µÄʵÌåµÄ±àÂë·½°¸ÓëʵÌåËùº¬±àÂëÉùÃ÷ÖÐÖ¸³öµÄ±àÂë·½°¸²»Í¬£¬±àÂëÉùÃ÷²»ÔÚÍⲿʵÌåµÄ¿ªÍ·£¬¼È²»ÒÔ×Ö½Ú´ÎÐò±ê¼Ç¿ªÍ·Ò²²»ÒÔ±àÂëÉùÃ÷¿ªÍ·µÄʵÌåʹÓÃÁ˲»Í¬ÓÚUTF-8µÄ±àÂë¡£×¢ÒâÒòΪASCIIÊÇUTF-8µÄÒ»¸ö×Ó¼¯£¬Ñϸñ˵À´ÆÕͨASCII×Ö·û²»ÐèÒª±àÂëÉùÃ÷¡£

µ±XML´¦ÀíÓöµ½µÄʵÌåʹÓÃÁËËü²»ÄÜ´¦ÀíµÄ±àÂëʱ£¬ÊÇÒ»¸öÑÏÖØ´íÎó¡£

±àÂëÉùÃ÷µÄÀý×Ó£º

<?xml encoding='UTF-8'?>
<?xml encoding='EUC-JP'?>

4.4 XML´¦ÀíÆ÷¶ÔʵÌåºÍÒýÓõĴ¦Àí

ϱí»ã×ÜÁË×Ö·ûÒýÓã¬ÊµÌåÒýÓ㬠ºÍ¶ÔδÎöʵÌåµÄµ÷ÓÿÉÒÔ³öÏÖµÄÉÏÏÂÎÄ£¬ÒÔ¼°Ã¿ÖÖÇé¿öÏÂXML´¦ÀíÆ÷µÄ¶¯×÷¡£ ×î×ó±ßÒ»ÁеıêÇ©Ö¸Ã÷ÁËʶ±ðʱµÄÉÏÏÂÎÄ£º

ÄÚÈÝÖеÄÒýÓÃ
¿ÉÒÔÔÚÔªËصÄÆðʼ±êÇ©Ö®ºó£¬½áÊø±êǩ֮ǰµÄÈκεط½ÒÔÒýÓÃÐÎʽ³öÏÖ£¬¶ÔÓ¦ÓÚ·ÇÖÕ½á·ûcontent¡£
ÊôÐÔÖµÖеÄÒýÓÃ
¿ÉÒÔÔÚÆðʼ±êÇ©ÄÚµÄÊôÐÔÖµÖУ¬»òÊôÐÔÉùÃ÷ÄÚµÄȱʡֵÖÐÒÔÒýÓÃÐÎʽ³öÏÖ;¶ÔÓ¦ÓÚ·ÇÖÕ½á·ûAttValue¡£
×÷ΪÊôÐÔÖµ
¿ÉÒÔÒÔName¶ø²»ÊÇÒÔÒýÓõÄÐÎʽ³öÏÖ£¬×÷ΪÉùÃ÷ΪENTITYÀàÐ͵ÄÊôÐÔµÄÖµ£¬»ò¿ÉÒÔ×÷ΪÉùÃ÷ΪENTITIESÀàÐ͵ÄÊôÐÔÖµÖеÄÒÔ¿Õ°×·Ö¸ôµÄ¼ÇºÅÖ®Ò»¡£
ʵÌåÖµÖеÄÒýÓÃ
¿ÉÒÔÔÚ²ÎÊýÖлòÄÚ²¿ÊµÌåµÄʵÌåÉùÃ÷Äڵij£Á¿ÊµÌåÖµÖÐÒÔÒýÓÃÐÎʽ³öÏÖ;¶ÔÓ¦ÓÚ·ÇÖÕ½á·ûEntityValue¡£
DTDÖеÄÒýÓÃ
¿ÉÒÔÔÚDTDµÄÄÚ²¿»òÍⲿ×Ó¼¯ÖÐÒÔÒýÓÃÐÎʽ³öÏÖ£¬µ«ÐëÔÚEntityValueºÍAttValueÖ®Íâ¡£
¡¡ ʵÌåÀàÐÍ ×Ö·û
²ÎÊý ÄÚ²¿ÆÕͨ ÍⲿÒÑÎöÆÕͨ δÎö
ÄÚÈÝÖеÄÒýÓà ²»±»Ê¶±ð ±»°üº¬ ½øÐÐÑé֤ʱ±»°üº¬ ±»½ûÖ¹ ±»°üº¬
ÊôÐÔÖµÖеÄÒýÓà ²»±»Ê¶±ð ×÷Ϊ³£Á¿±»°üº¬ ±»½ûÖ¹ ±»½ûÖ¹ ±»°üº¬
×÷ΪÊôÐÔÖµ ²»±»Ê¶±ð ±»½ûÖ¹ ±»½ûÖ¹ ֪ͨ ²»±»Ê¶±ð
ʵÌåÖµÖеÄÒýÓà ×÷Ϊ³£Á¿±»°üº¬ ²»´¦Àí ²»´¦Àí ±»½ûÖ¹ ±»°üº¬
DTDÖеÄÒýÓà ×÷ΪPE±»°üº¬ ±»½ûÖ¹ ±»½ûÖ¹ ±»½ûÖ¹ ±»½ûÖ¹

4.4.1 ²»±»Ê¶±ð(Not Recognized)

ÔÚDTDÖ®Í⣬°Ù·ÖºÅ×Ö·û%ûÓÐÌØÊ⺬Òå;Òò´ËÔÚDTDÖеIJÎÊýʵÌåÒýÓÃÔÚcontentÖв»±»µ±³É±ê¼Çʶ±ð¡£ÀàËƵأ¬³ý·ÇδÎöʵÌåµÄÃû×Ö³öÏÖÔÚÒÑÊʵ±ÉùÃ÷µÄÊôÐÔµÄÖµÖУ¬·ñÔòËüÃDz»±»Ê¶±ð¡£

4.4.2 ±»°üº¬(Included)

µ±Ò»¸öʵÌåµÄÖû»Îı¾±»µ±³É³öÏÖÔÚÒýÓÃËùÔÚλÖõÄÎļþµÄÒ»²¿·ÖÒ»Ñù±»´æÈ¡ºÍ´¦Àíʱ£¬³Æ´ËʵÌå±»°üº¬¡£ÆäÖû»Îı¾¿ÉÒÔ°üº¬×Ö·ûÊý¾ÝºÍ±ê¼Ç(²»°üÀ¨²ÎÊýʵÌå)£¬ÆäÖбê¼Ç±ØÐëÒÔͨ³£µÄ·½Ê½Ê¶±ð£¬µ«ÓÃÓÚתÒå±ê¼Ç¶¨½ç·û(ʵÌåamp£¬lt£¬gt£¬aposºÍquot)µÄʵÌåµÄÖû»Îı¾×ÜÊDZ»µ±³ÉÊý¾Ý¡£(×Ö·û´®"AT&amp;T;"Õ¹¿ªÎª"AT&T;"ÉдæµÄ"and"ºÅ&²»±»Ê¶±ðΪʵÌåÒýÓõĶ¨½ç·û¡£)µ±±»±íʾµÄ×Ö·û±»µ±³É³öÏÖÔÚÒýÓÃËùÔÚλÖÃÒ»Ñù±»´¦Àíʱ£¬³Æ´Ë×Ö·ûÒýÓñ»°üº¬¡£

4.4.3 ½øÐÐÑé֤ʱ±»°üº¬(Included If Validating)

µ±XML´¦ÀíÆ÷ʶ±ð³öÒ»¸ö¶ÔÒÑÎöʵÌåµÄÒýÓã¬ÎªÁËÑéÖ¤¸ÃÎļþ£¬´¦ÀíÆ÷±ØÐë°üº¬´ËʵÌåµÄÖû»Îı¾¡£Èç¹ûʵÌåÊÇÍⲿµÄ£¬¶ø´¦ÀíÆ÷²»ÊÔͼÑéÖ¤¸ÃXMLÎļþ£¬ÄÇô´¦ÀíÆ÷¿ÉÒÔ£¬µ«²»ÊDZØÐ룬°üº¬´ËʵÌåµÄÖû»Îı¾¡£Èç¹ûÒ»¸ö²»ÑéÖ¤µÄÓï·¨·ÖÎöÆ÷²»°üº¬´ËÖû»Îı¾£¬Ëü±ØÐë֪ͨӦÓÃËüʶ±ð³öµ«Ã»ÓжÁÈ¡´ËʵÌå¡£

ÕâÌõ¹æ·¶»ùÓÚÕâÑùÒ»¸ö¹²Ê¶£ºÓÉSGMLºÍXMLµÄʵÌå»úÖÆÌṩµÄÆð³õÉè¼ÆÓÃÓÚÖ§³ÖÄ£¿é»¯´´×÷µÄ×Ô¶¯°üº¬²»Ò»¶¨ÊʺÏÓÚÆäËûÓ¦Óã¬ÓÈÆäÊÇÎļþä¯ÀÀ¡£ÀýÈ磬µ±ä¯ÀÀÆ÷Óöµ½Ò»¸öÍⲿÒÑÎöʵÌåÒýÓÃʱ£¬¿ÉÄÜÑ¡ÔñÓÿÉÊÓ·½Ê½±íʾÆä´æÔÚµ«Ö»ÔÚ±»ÇëÇóʱ²Å¶ÁÈ¡Ëü½øÐÐÏÔʾ¡£

4.4.4 ±»½ûÖ¹(Forbidden)

ÒÔÏÂÇé¿ö±»½ûÖ¹£¬²¢¹¹³ÉÒ»¸öÑÏÖØ´íÎó£º

4.4.5 ±»°üº¬ÔÚ³£Á¿ÖÐ(Included in Literal)

µ±ÊµÌåÒýÓóöÏÖÔÚÊôÐÔÖµÖлò²ÎÊýʵÌåÒýÓóöÏÖÔÚ³£Á¿ÊµÌåÖµÖÐʱ£¬ËüÃǵÄÖû»Îı¾±»µ±³É³öÏÖÔÚÒýÓÃËùÔÚλÖõÄÎļþµÄÒ»²¿·ÖÒ»Ñù±»´æÈ¡ºÍ´¦Àí£¬Öû»Îı¾Öеĵ¥Ë«ÒýºÅ×ÜÊDZ»µ±³ÉÕý³£µÄÊý¾Ý×Ö·û¶ø²»»á½áÊø´Ë³£Á¿¡£ÀýÈ磬ÏÂÃæµÄÀý×ÓÊǹ淶µÄ£º

<!ENTITY % YN '"Yes"' >
<!ENTITY WhatHeSaid "He said &YN;" >

¶øÕâ¸öÀý×Ó²»ÊÇ£º

<!ENTITY EndAttr "27'" >
<element attribute='a-&EndAttr;>

4.4.6 ֪ͨ(Notify)

µ±Î´ÎöʵÌåÃû×Ö×÷Ϊ¼ÇºÅÔÚÉùÃ÷ΪENTITY»òENTITIESÀàÐ͵ÄÊôÐÔµÄÖµÖгöÏÖʱ£¬ ½øÐÐÑéÖ¤µÄ´¦ÀíÆ÷±ØÐ뽫´ËʵÌåºÍËüµÄÏà¹Ø¼Ç·¨µÄϵͳºÍ¹«¹²(Èç¹ûÓеĻ°)±êʶ·û֪ͨ¸øÓ¦Óá£

4.4.7 ²»´¦Àí(Bypassed)

µ±ÊµÌåÉùÃ÷ÄÚÒ»¸öÆÕͨʵÌåÒýÓóöÏÖÔÚEntityValueÖÐʱ£¬ Ëü²»±»´¦Àí£¬±£³Ö²»±ä¡£

4.4.8 ×÷ΪPE±»°üº¬(Included as PE)

ºÍÍⲿÒÑÎöʵÌåÒ»Ñù£¬²ÎÊýʵÌåÖ»ÐèÔÚ½øÐÐÑé֤ʱ±»°üº¬¡£µ±²ÎÊýʵÌåÒýÓÃÔÚDTDÖб»Ê¶±ð²¢±»°üº¬Ê±£¬ËüµÄÖû»Îı¾±»Ç°ºó¸÷¼ÓÉÏÒ»¸ö¿Õ¸ñ×Ö·û;ÆäÄ¿µÄÔÚÓÚÇ¿ÖƲÎÊýʵÌåµÄÖû»Îı¾°üº¬ÕûÊý¸öDTDÖеÄÓï·¨¼ÇºÅ¡£

4.5 ÄÚ²¿ÊµÌåÖû»Îı¾µÄ¹¹½¨(Construction of Internal Entity)

ÔÚÌÖÂÛÄÚ²¿ÊµÌåµÄ´¦Àíʱ£¬Çø·ÖÁ½ÖÖÐÎʽµÄʵÌåÖµÊÇÓаïÖúµÄ¡£³£Á¿ÊµÌåÖµ(literal entity value)ÊÇʵ¼Ê³öÏÖÔÚʵÌåÉùÃ÷ÖÐÓÃÒýºÅÀ©ÆðµÄ×Ö·û´®¡£¶ÔÓ¦ÓÚ·ÇÖÕ½á·ûEntityValue¡£Öû»Îı¾(replacement text)ÊÇÖû»ÁË×Ö·ûÒýÓúͲÎÊýʵÌåÒýÓúóµÄʵÌåÄÚÈÝ¡£

ÔÚÄÚ²¿ÊµÌåÉùÃ÷(EntityValue)Öиø³öµÄ³£Á¿ÊµÌåÖµ¿ÉÒÔ°üÀ¨×Ö·ûÒýÓ㬲ÎÊýʵÌåÒýÓúÍÆÕͨʵÌåÒýÓá£ÕâЩÒýÓñØÐë±»Õû¸ö°üº¬ÓÚ³£Á¿ÊµÌåÖµÖС£ÈçÇ°Êö·½Ê½±»°üº¬µÄʵ¼ÊÖû»Îı¾±ØÐë°üº¬ËùÓб»ÒýÓõIJÎÊýʵÌåµÄÖû»Îı¾£¬Í¬Ê±ËùÓб»ÒýÓõÄ×Ö·û±ØÐëÔÚ³£Á¿ÊµÌåÖµÖÐ×Ö·ûÒýÓÃËùÔÚλÖñ»°üº¬¡£µ«ÆÕͨʵÌåµÄÒýÓñØÐë±£³Ö²»±ä£¬²»±»Õ¹¿ª¡£ÀýÈ磬Èç¹ûÓÐÒÔϵÄÉùÃ÷£º

<!ENTITY % pub    "&#xc9;ditions Gallimard" >
<!ENTITY   rights "All rights reserved" >
<!ENTITY   book   "La Peste: Albert Camus, 
&#xA9; 1947 %pub;. &rights;" >

ÄÇôʵÌå"book"µÄÖû»Îı¾Îª£º

La Peste: Albert Camus, 
?nbsp;1947 Éditions Gallimard. &rights;

Ò»µ©ÒýÓÃ"&book;"³öÏÖÔÚÎļþµÄÄÚÈÝ»òÊôÐÔÖµÖÐʱ£¬ÆÕͨʵÌåÒýÓÃ"&rights;"Ó¦¸Ã±»Õ¹¿ª¡£

ÕâЩ¼òµ¥µÄ¹æÔò½«¿ÉÄÜ»áÓи´ÔÓµÄÏ໥×÷ÓÃ;²Î¼û"D. ÊµÌåºÍ×Ö·ûÒýÓõÄÕ¹¿ª"ÖжÔÒ»¸öÄѵÄÀý×ÓµÄÏêϸÌÖÂÛ¡£

4.6 Ô¤¶¨ÒåʵÌå(Predefined Entities)

ʵÌåºÍ×Ö·ûÒýÓö¼¿ÉÒÔÓÃÓÚתÒå×ó¼âÀ¨ºÅ£¬"and"ºÅ(&)ºÍÆäËû¶¨½ç·û¡£ÆÕͨʵÌ弯ºÏ(amp£¬lt£¬gt£¬apos£¬quot)רÃÅÓÃÓÚ´ËÄ¿µÄ¡£Ò²¿ÉÒÔʹÓÃÊýÖµ×Ö·ûÒýÓÃ; Ò»µ©±»Ê¶±ð£¬ËüÃÇÁ¢¼´±»Õ¹¿ª£¬Í¬Ê±ËüÃDZØÐë±»µ±³É×Ö·ûÊý¾Ý£¬Òò´ËÊýÖµ×Ö·ûÒýÓÃ"&#60;"ºÍ"&#38;"¿ÉÒÔÓÃÓÚתÒå³öÏÖÔÚ×Ö·ûÊý¾ÝÖеÄ<ºÍ&¡£

²»¹ÜÕâЩʵÌåÊÇ·ñ±»ÉùÃ÷£¬ËùÓеÄXML´¦ÀíÆ÷±ØÐëÄÜʶ±ðËüÃÇ¡£³öÓÚ»¥²Ù×÷ÐÔ¿¼ÂÇ£¬ÓÐЧµÄXMLÎļþÓ¦¸ÃÈçÆäËûʵÌåÒ»Ñù£¬ÔÚʹÓÃÕâЩʵÌåÇ°ÏÈÉùÃ÷ËüÃÇ¡£Èç¹ûÉùÃ÷µÄ»°£¬ÕâЩʵÌå±ØÐë±»ÉùÃ÷ΪÄÚ²¿ÊµÌ壬ÆäÖû»Îı¾ÊDZ»×ªÒåµÄµ¥¸ö×Ö·û»òÖ¸ÏòÕâ¸ö×Ö·ûµÄ×Ö·ûÒýÓá£ÈçÏÂËùʾ¡£

<!ENTITY lt     "&#38;#60;"> 
<!ENTITY gt     "&#62;"> 
<!ENTITY amp    "&#38;#38;"> 
<!ENTITY apos   "&#39;"> 
<!ENTITY quot   "&#34;"> 

×¢ÒâÔÚ"lt"ºÍ"amp"µÄÉùÃ÷ÖУ¬<ºÍ&±»Á½´ÎתÒ壬ÕâÊÇΪÁËÂú×ãʵÌåÖû»µÄ¹æ·¶ÐÔÒªÇó¡£

4.7 ¼Ç·¨ÉùÃ÷(Notation Declarations)

¼Ç·¨ÓÃÃû×Ö±êʶÁËδÎöʵÌåµÄ¸ñʽ£¬¾ßÓмǷ¨ÊôÐÔµÄÔªËصĸñʽÒÔ¼°´¦ÀíÖ¸ÁîËùÕë¶ÔµÄÓ¦Óõĸñʽ¡£

¼Ç·¨ÉùÃ÷¸³Óè¼Ç·¨Ò»¸öÃû×ÖÓÃÓÚʵÌåÖУ¬ÊôÐÔ±íÉùÃ÷ÖкÍÊôÐÔֵ˵Ã÷ÖУ¬Í¬Ê±Ò²¸ø³öÁËÒ»¸ö¼Ç·¨µÄÍⲿ±êʶ·ûʹµÃXML´¦ÀíÆ÷»òËüµÄ¿Í»§Ó¦ÓÿÉÒÔ¶¨Î»ÄÜÒÔ¸ø¶¨¼Ç·¨µÄ¸ñʽ´¦ÀíÊý¾ÝµÄÖúÀíÓ¦Óá£

¼Ç·¨ÉùÃ÷
[82]  NotationDecl ::= '<!NOTATION' S Name S (ExternalIDPublicID) S? '>'
[83]  PublicID ::= 'PUBLIC' S PubidLiteral

XML´¦ÀíÆ÷±ØÐëÏòÓ¦ÓÃÌṩÈκÎÔÚÊôÐÔÖµÖУ¬ÊôÐÔ¶¨ÒåÖлòʵÌåÉùÃ÷Öж¨Òå»òÒýÓõļǷ¨µÄÃû×ÖºÍÍⲿ±êʶ·û¡£ËüÃÇ»¹¿ÉÒÔ½«Íⲿ±êʶ·û½âÎö³Éϵͳ±êʶ·û£¬ÎļþÃû£¬»òÊÇÓ¦Óõ÷ÓÃÏàÓ¦´¦ÀíÆ÷´¦Àí¸ø¶¨¼Ç·¨¸ñʽµÄÊý¾ÝµÄËùÐèµÄÆäËûÐÅÏ¢¡£(µ«Èç¹ûXML´¦ÀíÆ÷»òÓ¦ÓÃËùÔËÐеÄϵͳÖÐûÓд¦ÀíXMLÎļþÉùÃ÷ºÍÒýÓõļǷ¨µÄÏàÓ¦Ó¦ÓõÄÇé¿ö£¬²»ÊÇÒ»¸ö´íÎó¡£)

4.8 ÎļþʵÌå(Document Entity)

ÎļþʵÌå(document entity)ÊÇʵÌåÊ÷µÄ¸ùºÍXML´¦ÀíÆ÷µÄ´¦ÀíÆðµã¡£±¾¹æ·¶Ã»Óй涨XMLÈçºÎ¶¨Î»ÎļþʵÌå;ÓëÆäËûʵÌ岻ͬ£¬ÎļþʵÌåûÓÐÃû×Ö£¬¶øÇÒ¿ÉÒÔÍêÈ«²»´øÈκαêʶµØ³öÏÖÔÚ´¦ÀíÆ÷µÄÊäÈëÁ÷ÖС£

5. Ò»ÖÂÐÔ(Conformance)

5.1 ½øÐÐÑéÖ¤ºÍ²»½øÐÐÑéÖ¤µÄ´¦ÀíÆ÷(Validating and Non-Validating Processors)

ºÏºõ¹æ·¶µÄXML´¦ÀíÆ÷¿ÉÒÔ·ÖΪÁ½Àࣺ½øÐÐÑéÖ¤µÄºÍ²»½øÐÐÑéÖ¤µÄ¡£

½øÐÐÑéÖ¤ºÍ²»½øÐÐÑéÖ¤µÄ´¦ÀíÆ÷¶¼±ØÐ뱨¸æÔÚÎļþʵÌåµÄÄÚÈÝÖкÍÈκÎÆäËûËüÃǶÁµ½µÄÒÑÎöʵÌåÖжԹ淶ÐÔÔ¼ÊøµÄÎ¥·´¡£

½øÐÐÑéÖ¤µÄ´¦ÀíÆ÷±ØÐ뱨¸æÎ¥·´DTDÉùÃ÷ÖÐËùÊöÔ¼ÊøµÄÇé¿öÒÔ¼°²»Âú×ã±¾¹æ·¶Öиø³öµÄÓÐЧÐÔÔ¼ÊøµÄÇé¿ö¡£ ÒªÍê³ÉÕâÒ»µã£¬½øÐÐÑéÖ¤µÄXML´¦ÀíÆ÷±ØÐë¶ÁÈ¡ºÍ´¦ÀíÕû¸öDTDºÍËùÓÐÔÚÎļþÖÐÒýÓõÄÍⲿÒÑÎöʵÌå¡£

²»½øÐÐÑéÖ¤µÄ´¦ÀíÆ÷Ö»±»ÒªÇó¼ì²éÎļþʵÌåºÍÕû¸öÄÚ²¿DTD×Ó¼¯µÄ¹æ·¶ÐÔ¡£ËäÈ»ËüÃDz»±»ÒªÇó¼ì²éÎļþµÄÓÐЧÐÔ£¬µ«ËüÃDZØÐë´¦ÀíËüÃǶÁÈ¡µÄËùÓÐÄÚ²¿DTD×Ó¼¯ÖеÄÉùÃ÷ºÍËùÓвÎÊýʵÌ壬ֱµ½Óöµ½µÚÒ»¸ö¶ÔËüÃÇûÓжÁÈ¡µÄ²ÎÊýʵÌåµÄÒýÓÃ;Ò²¾ÍÊÇ˵£¬ËüÃDZØÐë¸ù¾ÝÕâЩÉùÃ÷ÖеÄÐÅÏ¢¹æ·¶»¯ÊôÐÔÖµ£¬°üº¬ÄÚ²¿ÊµÌåµÄÖû»Îı¾£¬²¢ÌṩȱʡÊôÐÔÖµ¡£ËüÃÇÔÚÓöµ½µÚÒ»¸ö¶ÔËüÃÇûÓжÁÈ¡µÄ²ÎÊýʵÌåµÄÒýÓú󣬲»Ó¦´¦ÀíÆäºóµÄʵÌåÉùÃ÷»òÊôÐÔ±íÉùÃ÷£¬ÒòΪ´ËʵÌåÖаüº¬µÄÉùÃ÷¿ÉÄܸ²¸ÇÇ°ÃæµÄÉùÃ÷¡£

5.2 ʹÓÃXML´¦ÀíÆ÷

½øÐÐÑéÖ¤µÄ´¦ÀíÆ÷µÄÐÐΪÊǸ߶ȿÉÔ¤²âµÄ;Ëü±ØÐë¶ÁÈ¡ÎļþµÄËùÓв¿·Ö£¬±¨¸æËùÓжԹ淶ÐÔºÍÓÐЧÐÔµÄÎ¥·´¡£¶ÔÒ»¸ö²»½øÐÐÑéÖ¤µÄ´¦ÀíÆ÷µÄÒªÇóÒªµÍÒ»µã;Ëü²»ÐèÒª¶ÁÈ¡ÎļþʵÌåÒÔÍâµÄÈκÎÎļþ²¿·Ö¡£Õâ¶ÔXMLµÄ´¦ÀíÆ÷µÄÓû§¶øÑÔ¿ÉÄÜ»áÓÐÁ½¸öÖØÒªµÄÓ°Ï죺

ΪÁËʹ²»Í¬XML´¦ÀíÆ÷¼äµÄ»¥²Ù×÷ÓÐ×î´óµÄ¿É¿¿ÐÔ£¬ ʹÓò»½øÐÐÑéÖ¤µÄ´¦ÀíÆ÷µÄÓ¦Óò»Ó¦ÒÀÀµÓÚ²»ÒªÇóÕâЩ´¦ÀíÆ÷¾ß±¸µÄ¶¯×÷¡£ ÄÇЩҪÇóʹÓÃÈçȱʡֵ»òÔÚÍⲿʵÌåÖÐÉùÃ÷ÄÚ²¿ÊµÌåµÈ¹¦ÄܵÄÓ¦ÓÃÓ¦¸ÃʹÓýøÐÐÑéÖ¤µÄXML´¦ÀíÆ÷¡£

6. ¼Ç·¨(Notation)

±¾¹æ·¶ÖÐXMLµÄÐÎʽ»¯ÎÄ·¨ÓÃÒ»ÖÖ¼òµ¥µÄÀ©Õ¹°Í¿Æ˹·¶Ê½(Extended Backus-Naur Form£¬EBNF)¸ø³ö¡£ÎÄ·¨ÖеÄÿһÌõ¹æÔò¶¨ÒåÁËÒ»¸ö·ûºÅ£¬ÐÎʽÈçÏ£º

symbol ::= expression

Èç¹û·ûºÅÓÃÕýÔò±í´ïʽ¶¨Ò壬ÔòËüÒÔ´óд×Öĸ¿ªÍ·£¬ ·ñÔòÒÔСд×Öĸ¿ªÍ·¡£×Ö·û´®³£Á¿(literal strings)ÓÃÒýºÅÀ¨Æð¡£

ÔÚ¹æÔòÓұߵıí´ïʽÖУ¬ÒÔϱí´ïʽÓÃÓÚÆ¥ÅäÒ»¸ö»ò¶à¸ö×Ö·ûµÄ×Ö·û´®£º

#xN
NÊÇÒ»¸öÊ®Áù½øÖƵÄÕûÊý£¬µ±ISO/IEC 10646ÖÐij¸ö×Ö·ûµÄ¹æ·¶(UCS-4)´úÂëÖµ×÷ΪÎÞ·ûºÅ¶þ½øÖÆÊýÓëNÏàµÈʱ£¬´Ë±í´ïʽƥÅäÕâ¸ö×Ö·û¡£#xNÖеÄÇ°µ¼0ûÓÐÒâÒ壬ÔÚÏàÓ¦µÄ´úÂëÖµÖеÄÇ°µ¼0µÄ¸öÊýÔòÓÉËùÓÃ×Ö·û±àÂë·½°¸¾ö¶¨£¬¶ÔXMLûÓÐÒâÒå¡£
[a-zA-Z]£¬ [#xN-#xN]
ÓëÆäÖµÔÚÖ¸¶¨·¶Î§ÄÚµÄÈκÎ×Ö·ûÏàÆ¥Åä(º¬½ç£¬inclusive)¡£
[^a-z]£¬ [^#xN-#xN]
ÓëÆäÖµÔÚÖ¸¶¨·¶Î§Ö®ÍâµÄÈκÎ×Ö·ûÏàÆ¥Åä¡£
[^abc]£¬ [^#xN#xN#xN]
ÓëÈκβ»ÔÚ¸ø¶¨×Ö·û¼¯ÄÚµÄ×Ö·ûÏàÆ¥Åä¡£
"string"
ÓëÆ¥ÅäË«ÒýºÅÖÐËù¸ø×Ö·û´®µÄ³£Á¿×Ö·û´®ÏàÆ¥Åä¡£
'string'
ÓëÆ¥Åäµ¥ÒýºÅÖÐËù¸ø×Ö·û´®µÄ³£Á¿×Ö·û´®ÏàÆ¥Åä¡£

ÕâЩ·ûºÅ¿ÉÒÔ°´ÏÂÁз½Ê½×éºÏ£¬ÒÔÆ¥Åä¸ü¸´ÔÓµÄģʽ£¬ÆäÖÐAºÍB±íʾ¼òµ¥±í´ïʽ£º

(expression)
expression±»µ±³ÉÒ»¸öµ¥Ôª£¬¿ÉÒÔÏò±¾±íÃèÊöµÄÄÇÑù½øÐÐ×éºÏ¡£
A?
ÓëÁã¸ö»òÒ»¸öAÏàÆ¥Å䣬¼´A¿ÉÑ¡¡£
A B
ÓëAºó¸úBµÄģʽÏàÆ¥Åä¡£
A | B
ÓëABÖ®Ò»ÏàÆ¥Å䣬µ«²»Í¬Ê±Æ¥Åä¡£
A - B
ÓëÈκÎÆ¥ÅäAµ«²»Æ¥ÅäBµÄ×Ö·û´®ÏàÆ¥Åä¡£
A+
ÓëÒ»¸ö»ò¶à¸öAÏàÆ¥Åä¡£
A*
ÓëÁã¸ö»ò¶à¸öAÏàÆ¥Åä¡£

ÆäËûÔÚ²úÉúʽÖÐʹÓõļǷ¨ÓУº

/* ... */
×¢ÊÍ
[ wfc: ... ]
¹æ·¶ÐÔÔ¼Êø;ÓÃÃû×Ö±êʶһ¸ö¶ÔÓëij¸ö²úÉúʽÏà¹ØÁªµÄ¹æ·¶ÎļþµÄÔ¼Êø¡£
[ vc: ... ]
ÓÐЧÐÔÔ¼Êø;ÓÃÃû×Ö±êʶһ¸ö¶ÔÓëij¸ö²úÉúʽÏà¹ØÁªµÄÓÐЧÎļþµÄÔ¼Êø¡£

¸½Â¼

A. ²Î¿¼ÎÄÏ×

A.1 ÕýʽµÄ²Î¿¼ÎÄÏ×

IANA
(Internet Assigned Numbers Authority) Official Names for Character Sets£¬ ed. Keld Simonsen et al. See ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets.
IETF RFC 1766
IETF (Internet Engineering Task Force). RFC 1766: Tags for the Identification of Languages£¬ ed. H. Alvestrand. 1995.
ISO 639
(International Organization for Standardization). ISO 639:1988 (E). Code for the representation of names of languages. [Geneva]: International Organization for Standardization£¬ 1988.
ISO 3166
(International Organization for Standardization). ISO 3166-1:1997 (E). Codes for the representation of names of countries and their subdivisions -- Part 1: Country codes [Geneva]: International Organization for Standardization£¬ 1997.
ISO/IEC 10646
ISO (International Organization for Standardization). ISO/IEC 10646-1993 (E). Information technology -- Universal Multiple-Octet Coded Character Set (UCS) -- Part 1: Architecture and Basic Multilingual Plane. [Geneva]: International Organization for Standardization£¬ 1993 (plus amendments AM 1 through AM 7).
Unicode
The Unicode Consortium. The Unicode Standard£¬ Version 2.0. Reading£¬ Mass.: Addison-Wesley Developers Press£¬ 1996.

A.2 ÆäËû²Î¿¼ÎÄÏ×

Aho/Ullman
Aho£¬ Alfred V., Ravi Sethi£¬ and Jeffrey D. Ullman. Compilers: Principles, Techniques, and Tools. Reading: Addison-Wesley, 1986, rpt. corr. 1988.
Berners-Lee et al.
Berners-Lee, T., R. Fielding, and L. Masinter. Uniform Resource Identifiers (URI): Generic Syntax and Semantics. 1997. (Work in progress; see updates to RFC1738.)
Brüggemann-Klein
Brüggemann-Klein, Anne. Regular Expressions into Finite Automata. Extended abstract in I. Simon, Hrsg., LATIN 1992, S. 97-98. Springer-Verlag, Berlin 1992. Full Version in Theoretical Computer Science 120: 197-213, 1993.
Brüggemann-Klein and Wood
Brüggemann-Klein, Anne, and Derick Wood. Deterministic Regular Languages. Universität Freiburg, Institut für Informatik, Bericht 38, Oktober 1991.
Clark
James Clark. Comparison of SGML and XML. See http://www.w3.org/TR/NOTE-sgml-xml-971215.
IETF RFC1738
IETF (Internet Engineering Task Force). RFC 1738: Uniform Resource Locators (URL), ed. T. Berners-Lee, L. Masinter, M. McCahill. 1994.
IETF RFC1808
IETF (Internet Engineering Task Force). RFC 1808: Relative Uniform Resource Locators, ed. R. Fielding. 1995.
IETF RFC2141
IETF (Internet Engineering Task Force). RFC 2141: URN Syntax, ed. R. Moats. 1997.
ISO 8879
ISO (International Organization for Standardization). ISO 8879:1986(E). Information processing -- Text and Office Systems -- Standard Generalized Markup Language (SGML). First edition -- 1986-10-15. [Geneva]: International Organization for Standardization, 1986.
ISO/IEC 10744
ISO (International Organization for Standardization). ISO/IEC 10744-1992 (E). Information technology -- Hypermedia/Time-based Structuring Language (HyTime). [Geneva]: International Organization for Standardization, 1992. Extended Facilities Annexe. [Geneva]: International Organization for Standardization, 1996.

B. ×Ö·ûµÄ·ÖÀà(Character Classes)

¸ù¾ÝUnicode±ê×¼Öж¨ÒåµÄÌØÕ÷£¬×Ö·û±»·ÖΪ»ù×Ö·û(ÆäÖаüÀ¨Ã»ÓбäÒô·ûµÄÀ­¶¡×Öĸ)£¬±íÒâ×Ö·ûºÍ×éºÏ×Ö·û(ÆäÖаüÀ¨´ó¶àÊýµÄ±äÒô·û);ÕâЩÀàºÏÆðÀ´×é³ÉÁË×ÖĸÀà¡£Êý×ÖºÍÀ©Õ¹·û(extender)Ò²¸÷×Ô±»·Ö³ÉÀà¡£

×Ö·û
[84]  Letter ::= BaseCharIdeographic
[85]  BaseChar ::= [#x0041-#x005A] | [#x0061-#x007A] | [#x00C0-#x00D6] | [#x00D8-#x00F6] | [#x00F8-#x00FF] | [#x0100-#x0131] | [#x0134-#x013E] | [#x0141-#x0148] | [#x014A-#x017E] | [#x0180-#x01C3] | [#x01CD-#x01F0] | [#x01F4-#x01F5] | [#x01FA-#x0217] | [#x0250-#x02A8] | [#x02BB-#x02C1] | #x0386 | [#x0388-#x038A] | #x038C | [#x038E-#x03A1] | [#x03A3-#x03CE] | [#x03D0-#x03D6] | #x03DA | #x03DC | #x03DE | #x03E0 | [#x03E2-#x03F3] | [#x0401-#x040C] | [#x040E-#x044F] | [#x0451-#x045C] | [#x045E-#x0481] | [#x0490-#x04C4] | [#x04C7-#x04C8] | [#x04CB-#x04CC] | [#x04D0-#x04EB] | [#x04EE-#x04F5] | [#x04F8-#x04F9] | [#x0531-#x0556] | #x0559 | [#x0561-#x0586] | [#x05D0-#x05EA] | [#x05F0-#x05F2] | [#x0621-#x063A] | [#x0641-#x064A] | [#x0671-#x06B7] | [#x06BA-#x06BE] | [#x06C0-#x06CE] | [#x06D0-#x06D3] | #x06D5 | [#x06E5-#x06E6] | [#x0905-#x0939] | #x093D | [#x0958-#x0961] | [#x0985-#x098C] | [#x098F-#x0990] | [#x0993-#x09A8] | [#x09AA-#x09B0] | #x09B2 | [#x09B6-#x09B9] | [#x09DC-#x09DD] | [#x09DF-#x09E1] | [#x09F0-#x09F1] | [#x0A05-#x0A0A] | [#x0A0F-#x0A10] | [#x0A13-#x0A28] | [#x0A2A-#x0A30] | [#x0A32-#x0A33] | [#x0A35-#x0A36] | [#x0A38-#x0A39] | [#x0A59-#x0A5C] | #x0A5E | [#x0A72-#x0A74] | [#x0A85-#x0A8B] | #x0A8D | [#x0A8F-#x0A91] | [#x0A93-#x0AA8] | [#x0AAA-#x0AB0] | [#x0AB2-#x0AB3] | [#x0AB5-#x0AB9] | #x0ABD | #x0AE0 | [#x0B05-#x0B0C] | [#x0B0F-#x0B10] | [#x0B13-#x0B28] | [#x0B2A-#x0B30] | [#x0B32-#x0B33] | [#x0B36-#x0B39] | #x0B3D | [#x0B5C-#x0B5D] | [#x0B5F-#x0B61] | [#x0B85-#x0B8A] | [#x0B8E-#x0B90] | [#x0B92-#x0B95] | [#x0B99-#x0B9A] | #x0B9C | [#x0B9E-#x0B9F] | [#x0BA3-#x0BA4] | [#x0BA8-#x0BAA] | [#x0BAE-#x0BB5] | [#x0BB7-#x0BB9] | [#x0C05-#x0C0C] | [#x0C0E-#x0C10] | [#x0C12-#x0C28] | [#x0C2A-#x0C33] | [#x0C35-#x0C39] | [#x0C60-#x0C61] | [#x0C85-#x0C8C] | [#x0C8E-#x0C90] | [#x0C92-#x0CA8] | [#x0CAA-#x0CB3] | [#x0CB5-#x0CB9] | #x0CDE | [#x0CE0-#x0CE1] | [#x0D05-#x0D0C] | [#x0D0E-#x0D10] | [#x0D12-#x0D28] | [#x0D2A-#x0D39] | [#x0D60-#x0D61] | [#x0E01-#x0E2E] | #x0E30 | [#x0E32-#x0E33] | [#x0E40-#x0E45] | [#x0E81-#x0E82] | #x0E84 | [#x0E87-#x0E88] | #x0E8A | #x0E8D | [#x0E94-#x0E97] | [#x0E99-#x0E9F] | [#x0EA1-#x0EA3] | #x0EA5 | #x0EA7 | [#x0EAA-#x0EAB] | [#x0EAD-#x0EAE] | #x0EB0 | [#x0EB2-#x0EB3] | #x0EBD | [#x0EC0-#x0EC4] | [#x0F40-#x0F47] | [#x0F49-#x0F69] | [#x10A0-#x10C5] | [#x10D0-#x10F6] | #x1100 | [#x1102-#x1103] | [#x1105-#x1107] | #x1109 | [#x110B-#x110C] | [#x110E-#x1112] | #x113C | #x113E | #x1140 | #x114C | #x114E | #x1150 | [#x1154-#x1155] | #x1159 | [#x115F-#x1161] | #x1163 | #x1165 | #x1167 | #x1169 | [#x116D-#x116E] | [#x1172-#x1173] | #x1175 | #x119E | #x11A8 | #x11AB | [#x11AE-#x11AF] | [#x11B7-#x11B8] | #x11BA | [#x11BC-#x11C2] | #x11EB | #x11F0 | #x11F9 | [#x1E00-#x1E9B] | [#x1EA0-#x1EF9] | [#x1F00-#x1F15] | [#x1F18-#x1F1D] | [#x1F20-#x1F45] | [#x1F48-#x1F4D] | [#x1F50-#x1F57] | #x1F59 | #x1F5B | #x1F5D | [#x1F5F-#x1F7D] | [#x1F80-#x1FB4] | [#x1FB6-#x1FBC] | #x1FBE | [#x1FC2-#x1FC4] | [#x1FC6-#x1FCC] | [#x1FD0-#x1FD3] | [#x1FD6-#x1FDB] | [#x1FE0-#x1FEC] | [#x1FF2-#x1FF4] | [#x1FF6-#x1FFC] | #x2126 | [#x212A-#x212B] | #x212E | [#x2180-#x2182] | [#x3041-#x3094] | [#x30A1-#x30FA] | [#x3105-#x312C] | [#xAC00-#xD7A3]
[86]  Ideographic ::= [#x4E00-#x9FA5] | #x3007 | [#x3021-#x3029]
[87]  CombiningChar ::= [#x0300-#x0345] | [#x0360-#x0361] | [#x0483-#x0486] | [#x0591-#x05A1] | [#x05A3-#x05B9] | [#x05BB-#x05BD] | #x05BF | [#x05C1-#x05C2] | #x05C4 | [#x064B-#x0652] | #x0670 | [#x06D6-#x06DC] | [#x06DD-#x06DF] | [#x06E0-#x06E4] | [#x06E7-#x06E8] | [#x06EA-#x06ED] | [#x0901-#x0903] | #x093C | [#x093E-#x094C] | #x094D | [#x0951-#x0954] | [#x0962-#x0963] | [#x0981-#x0983] | #x09BC | #x09BE | #x09BF | [#x09C0-#x09C4] | [#x09C7-#x09C8] | [#x09CB-#x09CD] | #x09D7 | [#x09E2-#x09E3] | #x0A02 | #x0A3C | #x0A3E | #x0A3F | [#x0A40-#x0A42] | [#x0A47-#x0A48] | [#x0A4B-#x0A4D] | [#x0A70-#x0A71] | [#x0A81-#x0A83] | #x0ABC | [#x0ABE-#x0AC5] | [#x0AC7-#x0AC9] | [#x0ACB-#x0ACD] | [#x0B01-#x0B03] | #x0B3C | [#x0B3E-#x0B43] | [#x0B47-#x0B48] | [#x0B4B-#x0B4D] | [#x0B56-#x0B57] | [#x0B82-#x0B83] | [#x0BBE-#x0BC2] | [#x0BC6-#x0BC8] | [#x0BCA-#x0BCD] | #x0BD7 | [#x0C01-#x0C03] | [#x0C3E-#x0C44] | [#x0C46-#x0C48] | [#x0C4A-#x0C4D] | [#x0C55-#x0C56] | [#x0C82-#x0C83] | [#x0CBE-#x0CC4] | [#x0CC6-#x0CC8] | [#x0CCA-#x0CCD] | [#x0CD5-#x0CD6] | [#x0D02-#x0D03] | [#x0D3E-#x0D43] | [#x0D46-#x0D48] | [#x0D4A-#x0D4D] | #x0D57 | #x0E31 | [#x0E34-#x0E3A] | [#x0E47-#x0E4E] | #x0EB1 | [#x0EB4-#x0EB9] | [#x0EBB-#x0EBC] | [#x0EC8-#x0ECD] | [#x0F18-#x0F19] | #x0F35 | #x0F37 | #x0F39 | #x0F3E | #x0F3F | [#x0F71-#x0F84] | [#x0F86-#x0F8B] | [#x0F90-#x0F95] | #x0F97 | [#x0F99-#x0FAD] | [#x0FB1-#x0FB7] | #x0FB9 | [#x20D0-#x20DC] | #x20E1 | [#x302A-#x302F] | #x3099 | #x309A
[88]  Digit ::= [#x0030-#x0039] | [#x0660-#x0669] | [#x06F0-#x06F9] | [#x0966-#x096F] | [#x09E6-#x09EF] | [#x0A66-#x0A6F] | [#x0AE6-#x0AEF] | [#x0B66-#x0B6F] | [#x0BE7-#x0BEF] | [#x0C66-#x0C6F] | [#x0CE6-#x0CEF] | [#x0D66-#x0D6F] | [#x0E50-#x0E59] | [#x0ED0-#x0ED9] | [#x0F20-#x0F29]
[89]  Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 | #x0E46 | #x0EC6 | #x3005 | [#x3031-#x3035] | [#x309D-#x309E] | [#x30FC-#x30FE]

Ôڴ˶¨ÒåµÄ×Ö·ûÀà¿ÉÒÔ´ÓUnicode×Ö·û¿âÖÐÈçϵ¼³ö£º

C. XMLºÍSGML(·ÇÕýʽ)

XML±»Éè¼ÆΪSGMLµÄÒ»¸ö×Ó¼¯£¬±íÏÖÔÚÿһ¸öÓÐЧµÄXMLÎļþÓ¦¸ÃÒ²ÊÇÒ»¸öºÏºõ¹æ·¶µÄSGMLÎļþ¡£¶ÔXMLÔÚSGMLÖ®Íâ¶ÔÎļþËù¼ÓµÄÏÞÖƵÄÏêϸÌÖÂ۲μû[Clark]¡£

D. ʵÌåºÍ×Ö·ûÒýÓõÄÕ¹¿ª(·ÇÕýʽ)

±¾¸½Â¼ÖоÙÀý˵Ã÷ÁËÔÚ "4.4 XML´¦ÀíÆ÷¶ÔʵÌåºÍÒýÓõĴ¦Àí"Ò»½ÚÖй涨µÄʵÌåºÍ×Ö·ûÒýÓõÄʶ±ðºÍÕ¹¿ªµÄ´ÎÐò¡£

Èç¹ûÉùÃ÷°üº¬ÔÚDTDÖÐ

<!ENTITY example "<p>An ampersand (&#38;#38;) may be escaped
numerically (&#38;#38;#38;) or with a general entity
(&amp;amp;).</p>" >

ÄÇôXML´¦ÀíÆ÷½«ÔÚ¶ÔʵÌåÉùÃ÷½øÐÐÓï·¨·ÖÎöʱʶ±ð³ö×Ö·ûÒýÓ㬲¢ÔÚ½«ÏÂÃæµÄ×Ö·û´®´æΪʵÌå"example"µÄֵǰ½âÎöÕâЩ×Ö·ûÒýÓÃ:

<p>An ampersand (&#38;) may be escaped
numerically (&#38;#38;) or with a general entity
(&amp;amp;).</p>

ÎļþÖжÔ"&example;"µÄÒýÓûᵼÖ¶ÔÎı¾µÄÖØзÖÎö£¬´ËʱԪËØ"p"µÄÆðʼºÍ½áÊø±êÇ©±»Ê¶±ð£¬Èý¸öÒýÓñ»Ê¶±ðºÍÕ¹¿ª£¬Æä½á¹ûÊÇÒ»¸ö°üº¬ÏÂÃæÄÚÈÝ(ËùÓÐÊý¾Ý£¬ÎÞ¶¨½ç·û»ò±ê¼Ç)"p"ÔªËØ£º

An ampersand (&) may be escaped
numerically (&#38;) or with a general entity
(&amp;).

Ò»¸ö¸ü¸´ÔÓµÄÀý×Ó¿ÉÒÔÍêÕûµØ˵Ã÷ÕâЩ¹æÔòºÍËüÃǵÄ×÷Óá£ÔÚÏÂÃæµÄÀý×ÓÖУ¬ÐкŽö½öÊÇΪÁË·½±ã˵Ã÷¡£

1 <?xml version='1.0'?>
2 <!DOCTYPE test [
3 <!ELEMENT test (#PCDATA) >
4 <!ENTITY % xx '&#37;zz;'>
5 <!ENTITY % zz '&#60;!ENTITY tricky "error-prone" >' >
6 %xx;
7 ]>
8 <test>This sample shows a &tricky; method.</test>

Õâ¸öÀý×ӻᵼÖÂÏÂÁж¯×÷£º

E. È·¶¨ÐÍÄÚÈÝÄ£ÐÍ(·ÇÕýʽ)

³öÓÚ¼æÈÝÐÔ¿¼ÂÇ£¬ÒªÇóÔªËØÀàÐÍÉùÃ÷ÖеÄÄÚÈÝÄ£ÐÍÊÇÈ·¶¨Ð͵ġ£

SGMLÒªÇóÄÚÈÝÄ£ÐÍÊÇÈ·¶¨Ð͵Ä(Ëü³ÆΪ"ÎÞÆçÒåµÄ"); ÓÃSGMLϵͳÉú³ÉµÄXML´¦ÀíÆ÷¿ÉÄÜ»á°Ñ·ÇÈ·¶¨ÐÍÄÚÈÝÄ£ÐͱêΪ´íÎó¡£

ÀýÈ磬ÄÚÈÝÄ£ÐÍ((b, c) | (b, d))ÊÇ·ÇÈ·¶¨Ð͵ģ¬ÒòΪ¸ø¶¨Ò»¸ö³õʼb£¬·ÖÎöÆ÷ûÓÐÔÚÏòÇ°¿´ÒÔÖªµÀbºóÊÇʲôԪËØ֮ǰ£¬ÎÞ·¨ÖªµÀÆ¥ÅäÄ£ÐÍÖеÄÄĸöb¡£ÔÚÕâÖÖÇé¿öÏ£¬Á½¸ö¶ÔbµÄÒýÓÿÉÒÔ¼ò»¯³Éµ¥¸öµÄÒýÓã¬Ê¹µÃÄ£ÐͳÉΪ(b,(c | d))¡£´Ëʱ³õʼµÄbÖ»ºÍÄÚÈÝÄ£ÐÍÖеÄÒ»¸öÃû×ÖÃ÷È·Æ¥Åä¡£·ÖÎöÆ÷²»ÐèÒªÏòÇ°¿´ÆäºóµÄÄÚÈÝ¡£c»òd¶¼Äܱ»½ÓÊÜ¡£

¸üÐÎʽ»¯µÄ˵·¨£ºÊ¹ÓÃAho£¬SethiºÍUllmanËùÖø[Aho/Ullman]3.9½ÚÖеıê×¼Ëã·¨3.5£¬¿ÉÒÔ´ÓÄÚÈÝÄ£Ð͹¹Ôì³öÒ»¸öÓÐÏÞ״̬×Ô¶¯»ú¡£ÔںܶàÕâÑùµÄËã·¨ÖУ¬¶ÔÓ¦ÕýÔò±í´ïʽÖеÄÿһ¸öλÖÃ(¼´ÕýÔò±í´ïʽµÄÓï·¨Ê÷ÖеÄÿ¸öÒ¶×Ó½Úµã)£¬¶¼¹¹ÔìÒ»¸öË漯(follow set)£»Èç¹ûÈÎһλÖõÄË漯Öв»Ö¹Ò»¸öºó¼ÌλÖñ»±êΪͬһԪËØÀàÐÍʱ£¬ÄÇô´ËÄÚÈÝÄ£Ðͳö´í£¬²¢ÇÒ¿ÉÒÔ±»±¨Îª´íÎó¡£

´æÔÚ½«Ðí¶àµ«²»ÊÇËùÓзÇÈ·¶¨ÐÍÄÚÈÝÄ£ÐÍ×Ô¶¯¹æԼΪµÈ¼ÛµÄÈ·¶¨ÐÍÄ£Ð͵ÄËã·¨£»²Î¼ûBrüggemann-Klein 1991 [Brüggemann-Klein].

F. ×Ö·û±àÂëµÄ×Ô¶¯¼ì²â(·ÇÕýʽ)

XML±àÂëÉùÃ÷ÔÚʵÌåÖÐÒÔÄÚ²¿±êÇ©µÄ·½Ê½¹¤×÷£¬ÓÃÓÚÖ¸³öʹÓÃÁ˺ÎÖÖ×Ö·û±àÂ롣Ȼ¶ø£¬ÔÚXML´¦ÀíÆ÷ÄܶÁÈ¡Õâ¸öÄÚ²¿±êÇ©Ç°£¬ÏÔÈ»Ëü±ØÐëÖªµÀµ±Ç°Ê¹ÓõÄÊǺÎÖÖ×Ö·û±àÂ룭¶øÕâÕýÊÇ´ËÄÚ²¿±êÇ©ÒªÊÔͼָ³öµÄ¡£Í¨³£Çé¿öÏ£¬ÕâÊÇÒ»ÖÖÎÞ·¨½â¾öµÄÇé¿ö¡£µ«ÔÚXMLÖв¢·ÇÈç´Ë£¬ÒòΪXMLÔÚÁ½¸ö·½Ãæ¶ÔÕâÖÖÇéÐÎ×÷³öÁËÏÞÖÆ£º¼Ù¶¨Ã¿Ò»ÖÖʵÏÖÖ»Ö§³ÖÒ»¸öÓÐÏÞµÄ×Ö·û±àÂ뼯£¬²¢ÇÒ£¬ÎªÁËʹµÃÕý³£Çé¿öÏÂ×Ô¶¯¼ì²âÿ¸öʵÌåÖÐËùÓÃ×Ö·û±àÂë³ÉΪ¿ÉÄÜ£¬ÏÞÖÆÁËXML±àÂëÉùÃ÷µÄλÖúÍÄÚÈÝ¡£Í¬Ê±£¬ºÜ¶àÇé¿öϳýÁËXMLÊý¾ÝÁ÷±¾ÉíÖ®Í⣬ÁíÍ⻹ÓпÉÓõÄÐÅÏ¢Ô´¡£¸ù¾ÝXMLʵÌå½»¸ø´¦ÀíÆ÷ʱûÓлòÓÐÈκεĸ½´ø(Íⲿ)ÐÅÏ¢£¬¿ÉÒÔÇø·Ö³öÁ½ÖÖÇé¿ö¡£ÎÒÃÇÏÈ¿¼ÂǵÚÒ»ÖÖÇé¿ö¡£

ÒòΪÿһ¸ö·ÇUTF-8»òUTF-16¸ñʽµÄXMLʵÌå±ØÐëÒÔXML±àÂëÉùÃ÷¿ªÍ·£¬Æ俪ʼµÄ¼¸¸ö×Ö·û±ØÐëΪ'<?xml'£¬ÈκκϺõ¹æ·¶µÄ´¦ÀíÆ÷¿ÉÒÔÔÚÁ½µ½Ëĸö°Ëλ×éµÄÊäÈëºó£¬¼ì²â³öÊÊÓÃÓÚÏÂÁкÎÖÖÇé¿ö¡£ÔÚ¶ÁÕâÕűíʱ£¬ÖªµÀÕâЩÊÇÓаïÖúµÄ£ºÔÚUCS-4ÖУ¬'<'ÊÇ"#x0000003C"£¬'?'ÊÇ"#x0000003F"£¬UTF-16Êý¾ÝÁ÷µÄ×Ö½Ú´ÎÐò±ê¼ÇÒªÇóΪ"#xFEFF"¡£

ÕâÖÖ²ã´ÎµÄ×Ô¶¯¼ì²â×ãÒÔÓÃÓÚ¶ÁÈ¡XML±àÂëÉùÃ÷ºÍ·ÖÎö×Ö·û±àÂë±êʶ·û¡£×Ö·û±àÂë±êʶ·ûÈÔÈ»ÊDZØÐëµÄ£¬ËüÓÃÓÚÇø·Ö±àÂë·½°¸¼¯Öеĵ¥¸ö³ÉÔ±(ÀýÈç´Ó8859ÖÐÇø·Ö³öUTF-8£¬8859¸÷¸ö²¿·Ö¼äµÄÏ໥Çø·Ö£¬ÒÔ¼°Çø·ÖËùÓõÄÌض¨EBCDIC´úÂëÒ³£¬µÈµÈ)¡£

ÒòΪ±àÂëÉùÃ÷µÄÄÚÈÝÏÞÓÚASCII×Ö·û£¬Ò»µ©´¦ÀíÆ÷¼ì²âµ½Ê¹ÓõÄÊÇÄÄÒ»¸ö±àÂë·½°¸¼¯£¬ËüÄܹ»¿É¿¿µØ¶ÁÈ¡Õû¸ö±àÂëÉùÃ÷¡£ÒòΪÔÚʵ¼ÊÖУ¬ËùÓй㷺ʹÓõÄ×Ö·û±àÂ붼¿ÉÒÔ¹éÓÚÉÏÊöÖÖÀàÖУ¬XML±àÂëÉùÃ÷±£Ö¤ÁË¿É¿¿µÄÄÚǶ(in-band)×Ö·û±àÂë±ê×¢£¬¼´Ê¹ÊÇÔÚ²Ù×÷ϵͳ»ò´«ÊäЭÒ鼶µÄÍⲿÐÅÏ¢Ô´²¢²»¿É¿¿µÄÇé¿öÏ¡£

Ò»µ©´¦ÀíÆ÷¼ì²âµ½ËùÓõÄ×Ö·û±àÂ룬Ëü¾Í¿ÉÒÔ×÷³öºÏÊʵĶ¯×÷£¬»òÊÇÕë¶ÔÿÖÖÇé¿öµ÷Óõ¥¶ÀµÄÊäÈëÀý³Ì£¬»òÊǶÔÿ¸öÊäÈëµÄ×Ö·ûµ÷Óð汾ºÏÊʵÄת»»º¯Êý¡£

ºÍÈκÎ×Ô±ê×¢(self-labeling)µÄϵͳһÑù£¬Ò»µ©ÈκÎÈí¼þ¸Ä±äÁËʵÌåµÄ×Ö·û¼¯»òÆä±àÂë¶øûÓÐÏàÓ¦Ð޸ıàÂëÉùÃ÷µÄ»°£¬XMLµÄ±àÂëÉùÃ÷½«ÎÞ·¨¹¤×÷¡£×Ö·û±àÂë·½°¸µÄʵÏÖÕß±ØÐëСÐÄ×Ðϸ£¬ÒÔ±£Ö¤ÓÃÓÚ±êעʵÌåµÄÄÚ²¿ºÍÍⲿÐÅÏ¢µÄÕýÈ·ÐÔ¡£

µÚ¶þÖÖ¿ÉÄܵÄÇé¿öÊÇXMLʵÌåÓи½´øµÄÐÅÏ¢£¬ÈçÔÚһЩÎļþϵͳºÍÍøÂçЭÒéÖС£µ±¾ßÓжà¸öÐÅϢԴʱ£¬ËüÃǼäµÄÏà¶ÔÓÅÏȼ¶ºÍÊ×Ñ¡³åÍ»´¦Àí·½·¨±ØÐëÔÚ´«ÊäXMLµÄ¸ß²ãЭÒéÖиø³ö¡£ÀýÈ磬ÄÚ²¿±êÇ©ºÍÍⲿÎļþÍ·ÖеÄMIMEÀàÐͱêÇ©µÄÏà¶ÔÓÅÏȼ¶Ó¦¸ÃÊǶ¨Òåtext/xmlºÍapplication/xml MIMEÀàÐ͵ÄRFCÎĵµµÄÒ»²¿·Ö¡£È»¶ø³öÓÚ»¥²Ù×÷ÐÔ¿¼ÂÇ£¬½¨ÒéʹÓÃÏÂÁйæÔò¡£

ÕâЩ¹æÔòÖ»ÊÊÓÃÓÚȱÉÙЭÒ鼶ÎĵµÊ±µÄÇé¿ö£»ÌرðÊÇ£¬µ±Ïà¹ØRFCÖж¨ÒåÁËÕâЩtext/xmlºÍapplication/xml MIMEÀàÐÍʱ£¬RFCÖеĽ¨ÒéÈ¡´úÕâЩ¹æÔò¡£

G. W3C XML¹¤×÷×é(·ÇÕýʽ)

±¾¹æ·¶ÓÉW3C XML¹¤×÷×é(WG)Íê³É²¢Åú×¼·¢±í¡£¹¤×÷×éÅú×¼±¾¹æ·¶²¢Ò»¶¨±íʾËùÓеŤ×÷×éµÄ³ÉÔ±¶¼Ò»ÖÂͬÒâ±¾¹æ·¶¡£ÏÖÓкÍÒÔÇ°µÄXML¹¤×÷×é³ÉÔ±°üÀ¨£º

Jon Bosak, Sun (Chair); James Clark (Technical Lead); Tim Bray, Textuality and Netscape (XML Co-editor); Jean Paoli, Microsoft (XML Co-editor); C. M. Sperberg-McQueen, U. of Ill. (XML Co-editor); Dan Connolly, W3C (W3C Liaison); Paula Angerstein, Texcel; Steve DeRose, INSO; Dave Hollander, HP; Eliot Kimber, ISOGEN; Eve Maler, ArborText; Tom Magliery, NCSA; Murray Maloney, Muzmo and Grif; Makoto Murata, Fuji Xerox Information Systems; Joel Nava, Adobe; Conleth O'Connell, Vignette; Peter Sharpe, SoftQuad; John Tigue, DataChannel