Represent space and tab in XML tag

前端 未结 8 1454

How to represent space and tab in XML tag. Is there any special characters for them to represent.

8条回答
  •  一个人的身影
    2020-11-29 05:48

    New, expanded answer to an old, commonly asked question...

    Whitespace in XML Component Names

    Summary: Whitespace characters are not permitted in XML element or attribute names.

    Here are the main Unicode code points related to whitespace:

    • #x0009 CHARACTER TABULATION
    • #x0020 SPACE
    • #x000A LINE FEED (LF)
    • #x000D CARRIAGE RETURN (CR)
    • #x00A0 NO-BREAK SPACE
    • [#x2002-#x200A] EN SPACE through HAIR SPACE
    • #x205F MEDIUM MATHEMATICAL SPACE
    • #x3000 IDEOGRAPHIC SPACE

    None of these code points are permitted by the W3C XML BNF for XML names:

    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]
    NameChar      ::= NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] |
                      [#x203F-#x2040]
    Name          ::= NameStartChar (NameChar)*
    

    Whitespace in XML Content (Not Component Names)

    Summary: Whitespace characters are, of course, permitted in XML content.

    All of the above whitespace codepoints are permitted in XML content by the W3C XML BNF for Char:

    Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]
    /* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. */
    

    Unicode code points can be inserted as character references. Both decimal &#decimal; and hexadecimal &#xhex; forms are supported.

    • Hexadecimal  Decimal  Unicode Name
    •    or         CHARACTER TABULATION
    •    or         LINE FEED (LF)
    •    or         CARRIAGE RETURN (CR)
    •    or         SPACE
    •     or       NO-BREAK SPACE

提交回复
热议问题