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

RE: XML/XSL and ASP/IIS


Subject: RE: XML/XSL and ASP/IIS
From: Mike Dierken <mike@xxxxxxxxxxxxxxx>
Date: Thu, 3 Jun 1999 07:42:25 -0700

Passing parameters to an XSL stylesheet (or any XML file) is something that
pops up now and then.
The approach that I've taken is to use entity references inside the XML/XSL
file, and extend the 'DOM builder' class to adjust the value of the entities
when the DTD portion of the XML file is parsed, but before the body of the
XML file is parsed.

An example XML file would look like:

<!DOCTYPE layout [
 <!ENTITY baseResourcePath "/layouts/theme1/" >
 <!ENTITY username "Mr. Bigglesworth" >
]>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
  <xsl:template match="/">
    <HTML>
    Welcome &username;!<br />
    <img src='&baseResourcePath;welcome.gif' />
    </HTML>
  </xsl:template>
</xsl:stylesheet>


Since I use a Java XML processor that supports SAX events, it was pretty
easy to extend the base Document class to accept a list of name/value pairs
(a Hashtable) and adjust the entity values when the 'on DTD Parsed' event
occurred.

I wrote an article with sample Java code for the DataChannel XML Parser -
http://xdev.datachannel.com/press/lounge.html 
Let me know what you think.

Mike D
DataChannel


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



Current Thread
Keywords