This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Hitting the same node with two templates?
- From: Richard Rowell <richard at bowmansystems dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: 25 Sep 2002 17:01:08 -0500
- Subject: [xsl] Hitting the same node with two templates?
- Reply-to: xsl-list at lists dot mulberrytech dot com
Probably a newbie question, but I can't seem to find the answer in my
book. I want to process the same node twice, adding a different
attribute each time. I only want the node output once however. I'm
trying the snippit below but the first template seems to be ignored.
I'm sure there is a good explanation, and I would be ecstatic if someone
could share it with me.
<!-- adds in the odbid attribute for service items (just copies the
one from the client (grandparent) -->
<xsl:template match="client/service_items/service_item">
<xsl:copy>
<xsl:attribute name="odbid">
<xsl:value-of select="../../@odbid"/>
</xsl:attribute>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
<!-- give each grandchild that has children a record_id -->
<xsl:template match="client/*/*[*]">
<xsl:copy>
<xsl:choose>
<xsl:when test="@record_id"/>
<xsl:otherwise>
<xsl:attribute name="record_id">
<xsl:value-of select="concat('client(' , ../../@record_id,
')-',name(), '-', position())"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:copy-of select="@*"/>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:template>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list