|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to copy parts of an var into another ?
> Hello List,
>
> I have a var:
>
> <xsl:variable name="foo">
> <item name="a item">
> <value>1</value>
> </item>
> <item name="another item">
> <value>2</value>
> </item>
> </xsl:variable>
In XSLT 1.0, you cannot search inside a result tree fragment without using
your processor's node-set extension function. A better way to do this is
to put the data in another document and use the document() function to
parse the document, storing the result in a global variable:
<xsl:variable name="table" select="document('mytable.xml')" />
If you don't want to use a second document, put the data in the stylesheet,
but in a top-level element in an application-specific namespace:
<foo:table xmlns:foo="http://www.foo.com/tables">
<item name="a item">
<value>1</value>
</item>
<item name="another item">
<value>2</value>
</item>
</foo:table>
Then, use the document function to select the table into a variable:
<xsl:variable name="table" select="document('')/foo:table"
xmlns:foo="http://www.foo.com/tables" />
You can then use XPath expressions to find what you need:
<xsl:for-each select="$table/item[@name='a item']">
...
</xsl:for-each>
If you take a look at Dave Pawson's XSL FAQ, you'll find more information
about these techniques:
http://www.dpawson.co.uk/xsl/sect2/N4995.html
Dave
|
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








