RE: document() to get root node of xml file???
>Thanks for your reply! Do you ( or anybody else) happen to know how to use >the document() function to get to the root node of the xml file that you're >applying your stylesheet to? Or are there better, alternative ways of >getting your >xml file root node?? <xsl:template match="/">gets the root node remember this is actually different than the document element, obviously can get at this with a parameter or variable, <xsl:param name="root" select="/"> > Even more confusing, >he says that document('') is used to get the root node of the >stylesheet - what >would you do with that? he gives an example of what you would do with that, but as it's spread over several pages one could miss it, here's another: let's suppose you have in your stylesheet the following namespace declarations <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:lang="http://www.fictivedictionaries.com/dictionary" version="1.0"> and somewhere in the body of your stylesheet you had the following: <lang:strings xml:lang="da"> <lang:entry name="fuldexplorer"> Fuld Funktionalitet Internet Explorer 5.x </lang:entry> <lang:entry name="fuldNetscape"> Fuld Funktionalitet til Netscape </lang:entry> <lang:entry name="dynexplorer"> Dynamisk Tekst til Internet Explorer 5.x </lang:entry> <lang:entry name="plainexplorer"> kun Tekst Internet Explorer 5.x </lang:entry> </lang:strings> then you could have the following template <xsl:template match="/"> <b><xsl:value-of select="document('')//lang:strings[@xml:lang='da']/lang:entry[@name='fuldexp lorer']"/></b> </xsl:template> obviously you could parameterize the language attribute, in this way you can make up simple lookup dictionaries inside of your stylesheet without having to load an external document via the document() function. although I still like using the document() function for that. this was of more use back when you didn't have widespread ability to get at nodesets inside of parameters. 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