[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: document() to get root node of xml file???

Subject: RE: document() to get root node of xml file???
From: "Bryan Rasmussen" <bry@xxxxxxxxxx>
Date: Wed, 13 Feb 2002 09:49:04 +0100
get root node
>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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.