xsl-list
[Top] [All Lists]

Re: [xsl] Identifying duplicate nodes within a branch

2008-11-13 11:34:30
Thank you, Michael!  That worked perfectly.Whew. I can't tell you how
grateful I am.

Best regards,
Mark


On Thu, Nov 13, 2008 at 9:22 AM, Michael Ludwig <mlu(_at_)as-guides(_dot_)com> 
wrote:
Mark Peters schrieb:

Now I'm trying to identify the <column> nodes where duplicate @id
values exist. Where there are duplicates, I'd like to include the
nodes where the @file value is "doc." But the output should also
include the unique column nodes, all of which have a @file value of
"dev."

Hi Mark,

the following seems to do the trick:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 <xsl:output indent="yes"/>
 <xsl:key name="columns-by-id" match="column" use="@id"/>

 <xsl:template match="column[ @file = 'dev' ]">
   <xsl:if test="
     generate-id() =
     generate-id( key( 'columns-by-id', @id)[1])">
     <xsl:copy>
       <xsl:apply-templates select="@*|node()"/>
     </xsl:copy>
   </xsl:if>
 </xsl:template>

 <xsl:template match="@*|node()">
   <xsl:copy>
     <xsl:apply-templates select="@*|node()"/>
   </xsl:copy>
 </xsl:template>
</xsl:stylesheet>

Michael Ludwig

--~------------------------------------------------------------------
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>
--~--





-- 

Mark Peters
Senior Technical Writer
Saba Software

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>