|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Using document() and getting back to the original
Dan,
At 01:12 PM 3/22/2004, you wrote: More questions related to the stylesheet parameters and using a config file. The XSLT engine doesn't ever have a file "open". It merely refers to node trees, without caring how they are built (from a file or otherwise). As you know, nodes can be identified using XPath; but XPath is sensitive to context, which leads to your problem, since your context changes when you do something like apply-templates select="document('myfile.xml')" But nodes and node sets can also be bound to variables. Just as you can say <xsl:variable name="source1" select="document('source1.xml')"/> and thereby have a variable bound to the root node of the XPath rendition of the document retrieved by the function, so also can you do <xsl:variable name="config" select="/"/> (at the top level), which binds the root node of the "official" source tree (in your case, the config file) to the variable $config. This is handly, because it allows you, in any context at all, to look at the $config node or any of its descendants. So you might be matching a node from source1.xml, and you can still say things like <xsl:value-of select="$config//color[@file=current()] (which gets the value of the 'color' element descendant of the $config tree whose @file attribute is the same as the value of the current node). You can also be more specific, declaring bindings like <xsl:variable name="colors" select="//color"/> to collect all the <color> elements in your source file and bind them to $colors. Like any other globally-scoped variable in XSLT, $colors will be the same no matter where you use it. I hope this helps. Cheers, Wendell
|
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








