<xsl:template match="/">
<newdoc>
<xsl:for-each select="distinct-values(//foo/@name)">
<xsl:element name="{.}"/>
</xsl:for-each>
</newdoc>
</xsl:template>
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Nathan Potter [mailto:ndp(_at_)coas(_dot_)oregonstate(_dot_)edu]
Sent: 10 June 2008 17:51
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Cc: Nathan Potter
Subject: [xsl] Generating a collection of unique elements.
Greetings,
I have thought about this for a couple of days, and I don't
really have an ideas about how to get the result I want.
Maybe someone here can help!
In my source document there are a number of <foo> elements.
They all have a "name" attribute. They can occur as child
elements of any other element in the document, at any level
of nesting.
My XSL needs to process these <foo> elements and produce a
list of the unique names.
Source Example:
<doc>
<foo name="a" />
<foo name="d" />
<thing1>
<foo name="a" />
<foo name="b" />
<foo name="c" />
</thing1>
<thing2>
<foo name="a" />
<thing3>
<foo name="b" />
<foo name="c" />
</thing3>
<foo name="d" />
<foo name="e" />
</thing2>
</doc>
Desired Result:
<newDoc>
<a />
<b />
<c />
<d />
<e />
</newDoc>
Anybody have a suggestion?
Thanks,
Nathan
============================================================
Nathan Potter Oregon State University, COAS
ndp at coas.oregonstate.edu 104 Ocean. Admin. Bldg.
541 737 2293 voice Corvallis, OR 97331-5503
541 737 2064 fax
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--