Subject: [xsl] listing unique attributes From: Zack Brown <zbrown@xxxxxxxxxxxxxxx> Date: Tue, 14 Jan 2003 05:53:46 -0800 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] SAX2SAX XML Transformatio, Sherzod Ruzmetov | Thread | RE: [xsl] listing unique attributes, Américo Albuquerque |
[xsl] SAX2SAX XML Transformation, Sachdeva, Rajeev | Date | RE: [xsl] SAX2SAX XML Transformatio, Sherzod Ruzmetov |
Month |