[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Filter nodes by attribute and output disgarded dup

Subject: Re: Filter nodes by attribute and output disgarded dups
From: "Joerg Heinicke" <joerg.heinicke@xxxxxx>
Date: Mon, 7 Jan 2002 22:45:13 +0100
x20
> Here is my xsl attempts:
> <xsl:for-each
> select="//C03//PERSNAME[@ROLE='arr'](not[.=preceding::PERSNAME])">
>   <xsl:sort select="."/>
>     <LI><xsl:value-of select="."/>
>       <xsl:text>&#x20;&#x20;&#x20;&#x20;&#x20;:&#x20;</xsl:text>
>         <xsl:value-of select="count(.//PERSNAME[@ROLE='arr'])"/>
>     </LI>
> </xsl:for-each>

Hi Mike,

the not() has to be within the squared brackets. And the context of your
counting must be "brought back" to the root element. <xsl:for-each> changes
the context and .//PERSNAME is always 0.

But what's with keys? It's much to easier to do that with keys:

<xsl:key name="persnames" match="PERSNAME[@ROLE='arr']" use="."/>


<xsl:for-each select="//C03//PERSNAME[@ROLE='arr'][count(. |
key('persnames', .)[1] ) = 1]">
    <xsl:sort select="."/>
    <LI>
        <xsl:value-of select="concat(.,
'&#x20;&#x20;&#x20;&#x20;&#x20;:&#x20;', count(key('persnames',.)))/>
    </LI>
</xsl:for-each>

Regards,

Joerg

----- Original Message -----
From: "Mike Ferrando" <mikeferrando@xxxxxxxxx>


> Friends,
> I am attempting to pull node data conditioned by the attribute value.
>
> <PERSNAME ROLE="arr">Smith, John</PERSNAME>
>
> I am having trouble writing the syntax. The reason is that I am not
> sure how the syntax is delimited. I keep getting parsing errors
> "Unexpected token". I take it that I cannot have "[]" followed by
> "()". How can I write this using an attribute in the expression?
>
> What I would like to do is:
> 1. sort by name of arranger.
> 2. filter out the duplicates
> 3. capture the number of duplicates
> 4. output each name and the number of times it appears
>
> Here is my xml and my xsl:
>
> <C02>
>   <DID>
>     <UNITTITLE>
>       <PERSNAME ENCODINGANALOG="100$a">Abt, Franz</PERSNAME>
>     </UNITTITLE>
>   </DID>
>   <C03>
>     <DID>
>       <CONTAINER TYPE="BOX">22</CONTAINER>
>       <UNITTITLE ID="PV106">
>         <TITLE>Schalf wohl, du s&#252;sser Engel du, op. 139</TITLE>
>         <PERSNAME ENCODINGANALOG="700$a" ROLE="arr">Hennes,
> Aloys</PERSNAME>
>         <GEOGNAME ENCODINGANALOG="260$a">London</GEOGNAME>
>         <CORPNAME ENCODINGANALOG="260$b">Ent. Stat Hall</CORPNAME>
>         <UNITDATE ENCODINGANALOG="260$c">[n.d.]</UNITDATE>
>         </UNITTITLE>
>     </DID>
>     <ODD>
>       <P>
>         <SUBJECT>For piano</SUBJECT>
>       </P>
>     </ODD>
>   </C03>
> </C02>
>
> Here is my xsl attempts:
> <xsl:for-each
> select="//C03//PERSNAME[@ROLE='arr'](not[.=preceding::PERSNAME])">
>   <xsl:sort select="."/>
>     <LI><xsl:value-of select="."/>
>       <xsl:text>&#x20;&#x20;&#x20;&#x20;&#x20;:&#x20;</xsl:text>
>         <xsl:value-of select="count(.//PERSNAME[@ROLE='arr'])"/>
>     </LI>
> </xsl:for-each>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.