Re: Unparsed entities (was RE: Special entity characters in Shift-JIS XSL).

Subject: Re: Unparsed entities (was RE: Special entity characters in Shift-JIS XSL).
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 20 Dec 1999 11:29:34 GMT
> can I specify a DOCTYPE in my stylesheet?
yes

<!DOCTYPE xsl:stylesheet [
<!ENTITY API  "this" >
]>

....

    <xsl:template match="/index">
    <general>
        <title>&API; Index</title>

but then &API; will be expanded by the xml parser as it parses the
stylesheet so the xsl engine will see  
<title>this Index</title>
In which case there may or may not be any point in having the entity,
you could have just written "this index" in place.

You can probably more usefully share the dtd with your original
document, if that alrady has a definition of the entity:

<!DOCTYPE xsl:stylesheet SYSTEM "..\..\docs\dtds\general.dtd" >

This only works if your xsl system uses a non validating parser that
does read external entities. (They are not required to be read according
to the xml spec.)

Note that both of these solutions put `this' into your output.
If you really want `&API' then you don't need a doctype in your
stylesheet at all just use
  <title>
  <xsl:text disable-output-escaping="yes">&amp;API; Index<xsl:text>
  </title>

Note however this last solution only works if you know the output tree
is going to be linearised into a file and then reparsed as XML.
If instead the result tree is being stuffed straight to a renderer or
other XML application as an XML tree, then the receiver will get
the characters & A P I ; not an entity reference.

David


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


Current Thread