xml, html or xhtml in : Which is the better choice?

后端 未结 3 1693
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-20 15:20

For historic reasons we have a mixture of


and


         


        
3条回答
  •  天涯浪人
    2020-12-20 15:58

    I found the answer by reading the XSLT 2.0 specification (XSLT 2.0 and XQuery 1.0 Serialization).

    Given an empty instance of an XHTML element whose content model is not EMPTY (for example, an empty title or paragraph) the serializer MUST NOT use the minimized form. That is, it MUST output

    and not

    .

    Given an XHTML element whose content model is EMPTY, the serializer MUST use the minimized tag syntax, for example
    , as the alternative syntax

    allowed by XML gives uncertain results in many existing user agents. The serializer MUST include a space before the trailing />, e.g.
    ,


    and Karen.

    The serializer MUST NOT use the entity reference ' which, although legal in XML and therefore in XHTML, is not defined in HTML and is not recognized by all HTML user agents.

    The serializer SHOULD output namespace declarations in a way that is consistent with the requirements of the XHTML DTD if this is possible. The XHTML 1.0 DTDs require the declaration xmlns="http://www.w3.org/1999/xhtml" to appear on the html element, and only on the html element. The serializer MUST output namespace declarations that are consistent with the namespace nodes present in the result tree, but it MUST avoid outputting redundant namespace declarations on elements where the DTD would make them invalid.

    That means the answer is using .

提交回复
热议问题