Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: [xsl] Help with XPath statement

From: Raymond Bissonnette <raybiss@----------->
To:
Date: 3/1/2008 11:23:00 PM
Hi Ken,

I'm sorry or the lack of precision.

I'm stuck with XSLT 1.0 (ASP.NET) and worse, what I'm after is to get a list
of <set ... > nodes with the SelectNodes method of an XmlDocument.

I guess I might have to get these elements another way.

Thanks,
Raymond





-----Original Message-----
From: G. Ken Holman [mailto:gkholman@xxxxxxxxxxxxxxxxxxxx] 
Sent: Saturday, March 01, 2008 5:55 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] 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.
>
><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

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="&#xa;"/>
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


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent