|
Subject: RE: [xsl] Generating a collection of unique elements. From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Tue, 10 Jun 2008 17:58:07 +0100 |
<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@xxxxxxxxxxxxxxxxxxxx]
> Sent: 10 June 2008 17:51
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> 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
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Generating a collection of un, Nathan Potter | Thread | RE: [xsl] Generating a collection o, Scott Trenda |
| RE: [xsl] Norwegian sort collation, Michael Kay | Date | RE: [xsl] Generating a collection o, Scott Trenda |
| Month |