Hi Zack.
This is a group problem. You want to group by section and by @who.
These templates gives the result you want.
<!-- this key gets all quotes grouped by section and @who -->
<xsl:key name="quotes" match="quote"
use="concat(generate-id(ancestor::section),'-',@who)"/>
<xsl:template match="section">
<span>Section <xsl:value-of select="position()"/></span><br/><!-- just
displaying the current section -->
<xsl:text>--------------------------------------------------------------
------</xsl:text><br/>
<xsl:apply-templates
select=".//quote[generate-id()=generate-id(key('quotes',concat(generate-
id(ancestor::section),'-',@who)))]"/><!-- this will get the diferent
quotes of this section -->
<br/>
<xsl:text>--------------------------------------------------------------
------</xsl:text><br/>
</xsl:template>
<xsl:template match="quote">
<xsl:if test="position()>1">
<xsl:text>, </xsl:text>
</xsl:if>
<a href="quotes/{(_at_)who}(_dot_)html"><xsl:value-of select="@who"/></a>
</xsl:template>
Hope this helps you.
-----Original Message-----
From: owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
[mailto:owner-xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com] On Behalf Of
Zack Brown
Sent: terça-feira, 14 de Janeiro de 2003 13:54
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] listing 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())">, </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>, <a href="quotes/person
B.html">person B</a>, <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
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list