xmlxhtmlschemadoctypedtd

how to embed XHTML in XML without DOCTYPE, CDATA or escapes?


Is there any way embed XHTML entity references into XML text without the DOCTYPE DTD declaration? The DOCTYPE line is causing problems on the java server it's targeting.

Escaping the &; sequence isn't acceptable, nor is embedding in CDATA. The references need to be validated.

Is is possible to reference the DTD from the schema definition instead of the XML data file.

More broadly speaking, what is the common practice for embedding XHTML (or at least entity references) in XML and having that validated?

One potential solution is to convert the entire XHTML 1.0 DTD to a schema, but this doesn't sound like the best idea.


Solution

  • Have you tried a DOCTYPE without PUBLIC or SYSTEM identifiers?

    You can either add the ENTITY declarations directly to the internal subset:

    <!DOCTYPE foo [
    <!ENTITY nbsp   "&#160;">
    <!ENTITY copy   "&#169;">
    <!ENTITY laquo  "&#171;">
    <!ENTITY reg    "&#174;">
    <!ENTITY deg    "&#176;">
    <!ENTITY plusmn "&#177;">
    <!ENTITY sup2   "&#178;">
    <!ENTITY sup3   "&#179;">
    <!ENTITY frac14 "&#188;">
    <!ENTITY frac12 "&#189;">
    <!ENTITY frac34 "&#190;">
    ]>
    <foo/>
    

    or you can use a parameter entity to point to an external file/files that have your ENTITY declarations:

    <!DOCTYPE foo [
    <!ENTITY % ents SYSTEM "xhtml-lat1.ent">
    %ents;
    ]>
    <foo/>