[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Can DOCTYPE survive transformation


Subject: Re: [xsl] Can DOCTYPE survive transformation
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 21 Jun 2006 13:17:18 -0400

Hi Rick,

At 11:53 AM 6/21/2006, you wrote:
I have an xml document with a doctype and some entity references as shown below. Is there a way to have them carry through to my output document? Thanks in advance.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE UpdateNote SYSTEM "file:///C:/Program%20Files/Adobe/FrameMaker7.2/structure/UpdateNoteAPP/UpdateNote.dtd" [


<!-- Begin Document Specific Declarations -->

<?Fm Validation Off?>

<!NOTATION tif SYSTEM "TIF">
<!ENTITY TN SYSTEM "file:///G:/marketing/framemaker/xml/imgUpdate/TN.tif" NDATA tif>


<!-- End Document Specific Declarations -->

]>

Unfortunately, the answer is "not really". XSLT works on a parsed representation of the input file, the "tree", in which no entities are present and no signs are left that there ever were entities.


Frequently, when people face this requirement they resort to non-XSLT workarounds. These include things like escaping the entities with a pre-process (so that &entity; comes out as &amp;entity; etc.), and unescaping them as a post-process, or similar tricks and techniques.

XSLT 2.0 does support better control of the serializer than XSLT 1.0, including character maps, so as long as you are happy to get your references normalized, that may also be an option.

Your sample, however, shows not entity references but an entity *declaration* in the DTD internal subset (and it's an unparsed entity). This is a different kettle of fish (though perhaps no more palatable). A post-process to drop this chunk of code into the output is probably the way to go ... or if your transformation is serialized immediately, you could resort to tag-writing using disable-output-escaping (assuming your processor supports it), and write the entire DOCTYPE declaration as a string literal.

At least in the past, Saxon has also had extension functions to work around this limitation. If you're using Saxon you should look into it.

Ask again if you need more details.

Cheers,
Wendell


Current Thread
Keywords