How do I define HTML entity references inside a valid XML document?

后端 未结 2 2031
南笙
南笙 2020-11-30 09:05

I need to be able to reference named HTML entities like instead of the Unicode alternative in an XML document. I have contr

相关标签:
2条回答
  • 2020-11-30 09:39

    If you can modify the the XML to include an inline DTD you can define the entities there:

    <!DOCTYPE yourRootElement [
        <!ENTITY bull "&#8226;">
        ....
    ]>
    
    0 讨论(0)
  • 2020-11-30 09:39

    I'm not cetain, but I think the XHTML DTD's should give you quite a few entities (253):

    http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Entities_representing_special_characters_in_XHTML

    Also in the w3 spec, there is a mention of additional DTD's for special characters etc. http://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_dtd_xhtml_character_entities

    However I haven't been able to find an implementation example of the special character DTDs.


    Edit by DevNull

    Here is an extremely generic example implementation of one of the entity DTD modules. To implement, you only need to add a parameter entity pointing to the module.

    <?xml version="1.0"?>
    <!DOCTYPE test [
    <!ELEMENT test (#PCDATA)>
    <!ENTITY % xhtml-special SYSTEM "xhtml-special.ent">
    %xhtml-special;
    ]>
    <test>Here is a left double quote: &ldquo;</test>
    
    0 讨论(0)
提交回复
热议问题