This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Hitting the same node with two templates?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]