Subject: Re: [xsl] Help with XPath statement From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Sat, 01 Mar 2008 17:54:56 -0500 |
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.
<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>
In this case:
jazz vocal pop rock
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: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>
-- World-wide corporate, govt. & user group XML, XSL and UBL training RSS feeds: publicly-available developer resources and training G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Help with XPath statement, Raymond Bissonnette | Thread | RE: [xsl] Help with XPath statement, Raymond Bissonnette |
[xsl] Help with XPath statement, Raymond Bissonnette | Date | Re: [xsl] Transform param name to t, G. Ken Holman |
Month |