Well formed XML? XML references within tag names and attribute names

后端 未结 3 755
没有蜡笔的小新
没有蜡笔的小新 2021-01-19 08:24

I have been searching trying to confirm my reading of the XML spec. My interpretation is that pre-defined entities and numeric character references are not allowed in tag n

3条回答
  •  攒了一身酷
    2021-01-19 08:45

    In digging around at w3.org, I found the following relevant pieces:

    [41] Attribute ::= Name Eq AttValue [VC: Attribute Value Type] [WFC: No External Entity References] [WFC: No < in Attribute Values]

    [WFC: No External Entity References] links to:

    Well-formedness constraint: No External Entity References
    Attribute values MUST NOT contain direct or indirect entity references to external entities.

    Name links to:

    [5] Name ::= NameStartChar (NameChar)*

    [4] NameStartChar ::= ":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]

    [4a] NameChar ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]

    Yes, it's as clear as mud! My interpretation of this would be that you could use hex entity references as long as they fell in the ranges specified above but that you could not use pre-defined references.

    I would expect a well-formed error when the names don't conform to this.

提交回复
热议问题