|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: XML/XSL and ASP/IIS
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








