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

listing unique attributes

Subject: listing unique attributes
From: Zack Brown <zbrown@xxxxxxxxxxxxxxx>
Date: Tue, 14 Jan 2003 05:53:46 -0800
unique attributes
Hi folks,

I'm having a problem creating a list of items from a set of items within a
given tag. I have a file that looks like this:

--------------------------------------------------------------------
<?xml version="1.0" ?>
<kc>
<section>

<p>some text <quote who="person A">more text</quote> more text <quote
who="person B">more text</quote> and more.</p>

<quote who="person A">
<p>text</p>
</quote>

<p>text <quote who="person B">more text</quote></p>

<p>

<ul>

<li>text <quote who="person C">text</quote></li>

</ul>

</p>

</section>

<section>
<quote who="person C"></quote>
</section>

</kc>
--------------------------------------------------------------------

in other words, within a <section> tag, there may be <quote> tags by
themselves, or <quote> tags nested within other tags. The "who" attribute of
a quote tag is a person's name. "who" attributes may repeat in a given section.

I have an xslt recipe that looks like this:

--------------------------------------------------------------------
<xsl:template match="kc/section" mode="full">
<xsl:if test=".//quote">
Quoted:
    <xsl:for-each select=".//@who[not(following-sibling::quote/@who=.)]">
<a href="quotes/{.}.html"><xsl:value-of select="."/></a>
        <xsl:if test="not(position() = last())">,&#160;</xsl:if>
    </xsl:for-each>
</xsl:if>
</xsl:template>
--------------------------------------------------------------------

What I would like is for this recipe to produce the following output
when applied to the first <section> in the file above:

--------------------------------------------------------------------
<a href="quotes/person A.html">person A</a>,&#160;<a href="quotes/person
B.html">person B</a>,&#160;<a href="quotes/person C.html">person C</a>
--------------------------------------------------------------------

and when applied to the second <section> in the file above:

--------------------------------------------------------------------
<a href="quotes/person C.html">person C</a>
--------------------------------------------------------------------

In other words, each person should only be listed once for a given
section, no matter how many times they appear in that section.

But I can't seem to make it go somehow. Could someone please give me a
hand?

Many thanks,
Zack

-- 
Zack Brown

 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.