[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] current node attribute as predicate
I use only a subset of the XML file to be processed as templates. The rest of the XML is source data from which to read certain values relating it to the current node via an attribute of the current node. The only way I know of that works is using a variable to which I assign the attribute, then by using the variable in the predicate. Apologies if this is a really basic question. Here is an example: XML ________________________________________ <?xml version="1.0" encoding="utf-8" ?> <inventory> <item itemcode="Item1"> <price>10.50</price> <description>description 1</description> </item> <item itemcode="Item2"> <price>20.00</price> <description>description 2</description> </item> <invoice> <date>19/12/2002</date> <purchase item="Item2" number="2" /> <purchase item="Item1" number="1" /> </invoice> </inventory> XSLT _____________________________________________________ <?xml version="1.0" encoding="UTF-8" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="invoice"> <xsl:apply-templates /> </xsl:template> <xsl:template match="purchase"> <xsl:variable name="ItemText"> <xsl:value-of select="@item" /> </xsl:variable> <xsl:copy-of select="/inventory/item[@itemcode=$ItemText]" /> </xsl:template> <xsl:template match="item" /> </xsl:stylesheet> 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
|