Re: [xsl] XSLT Help is needed

Subject: Re: [xsl] XSLT Help is needed
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 14 Oct 2004 13:41:21 +0100
> XML will be created by application.Is it possible to create DTD using
> MSXML??

ah you want to _write_ that format using XSLT?
Hmm the answer to that is a bit complicated.

Short answer: No.

Longer answer: Probably not.

If you are using MSXML then from XSLT you generate a result tree
(essentially a standard MSXML DOM) and from there you serialise that DOM
into an XML document. There are two ways of doing that, you might get
XSLT processor to do the serialisation directly to a string or file in
which case the serialisation can be customised using xsl:output, and the
comments below apply. Or you can output a DOM node from the XSLt engine
and later serialise that node eg using its .xml method. In that case
nothing you do on xsl:output will make any difference (and the answer to
your question is no, you can't really generate entity references in that
case from XSLT).

So, if you are still here, then you can generate a reference to a DTD
(which you need to produce separately) by adding
<xsl:output doctype-system="mydtd.dtd"/>
to your XSLT file, and assuming mydtd contains
<!ENTITY imgURL "http://localhost:7001/WAT/wat/images"; > 

Then you can generate entity references by going

<xsl:text disable-output-escaping="yes">&amp;imgURL;</xsl:text>

However you can not use disable-output-escaping for attribute values,
only for element content, so since you want this in an attribute value
you would have to output the entire tag as text:

<xsl:text disable-output-escaping="yes">
&lt;img src="&amp;imgURL;/viewdocument.gif" width="123" height="20" border="0"&gt;
</xsl:text>

This is fairly horrible, but if you _really_ need to have that entity
reference and generate it from MSXML's XSLt engine then that is probably
your only choice.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread