|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Help with XPath statement
At 2008-03-01 17:34 -0500, Raymond Bissonnette wrote:
Given the following xml, I'd like to get the 0803 (last) section's set elements + the 0802 (before last) set elements that are not already in 0803. This is one function call in XSLT 2 and some preparatory work in XSLT 1. You don't say what governs the order. Examples are below ... I hope this helps. . . . . . . . Ken t:\ftemp>type raymond.xml
<application>
<section id="0802">
<set key="jazz" value="4" />
<set key="pop" value="61" />
<set key="rock" value="43" />
</section>
<section id="0803">
<set key="jazz" value="2" />
<set key="vocal" value="2" />
</section>
</application>t:\ftemp>type raymond.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="text"/> <xsl:key name="keys" match="@key" use="."/> <xsl:template match="/">
XSLT 2:
<xsl:value-of select="distinct-values(//@key)" separator="
"/>
XSLT 1:
<xsl:for-each select="//@key[generate-id(.)=
generate-id(key('keys',.)[1])]">
<xsl:if test="position()>1" xml:space="preserve">
</xsl:if>
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template></xsl:stylesheet> t:\ftemp>xslt2 raymond.xml raymond.xsl con XSLT 2: jazz pop rock vocal XSLT 1: jazz pop rock vocal t:\ftemp>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Cast Your Vote
We need your help – Vote for DataDirect XML Products!
Winners and finalists announced at SOA World Conference in November. 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
|







