[xsl] Setting doctype-system attribute of xsl-output element

Subject: [xsl] Setting doctype-system attribute of xsl-output element
From: Graham Hannington <Ghannington@xxxxxxx>
Date: Tue, 4 Nov 2003 12:02:55 -0000
I have an XSLT stylesheet that outputs XML* with entity references
preserved.
(*Very close to XHTML, but with a few custom attributes and other
modifications, for which I've created a custom DTD.)

To allow entity references in the result tree, my XSLT processor (MSXML 3)
requires the <xsl:output> element in the XSLT stylesheet to specify a DTD
that defines the entity references.

To begin with, I added an "http://..."; reference to the XHTML DTD on the
Web, but this slowed the transform.

So I looked at pointing the doctype-system attribute at a local copy of the
DTD.
Now, this might be all very MSXML-specific (and will likely prompt lots of
"well, duh" reactions), but perhaps it might help someone, or otherwise
prompt a "try this other way, it's much better" response.

Before calling the transformNode... method, you can tweak the doctype-system
attribute via:

objXSLT.documentElement.selectSingleNode("xsl:output").setAttribute
"doctype-system", strDTDPath

where strDTDPath is the (typically, absolute) path of a DTD file on your
file system (for example, "c:\dtd\xhtml.dtd").

But what I've ended up doing is hardcoding a relative path in doctype-system
and then, prior to calling the transformNode... method, the script sets the
system current directory so that the relative path resolves to the correct
file:

WshShell.CurrentDirectory = strSourceFolderPath

This works fine, and the transform is now much faster.










 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread