RE: [xsl] Parameterizing an XML using a XSLT

Subject: RE: [xsl] Parameterizing an XML using a XSLT
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Wed, 9 Apr 2003 20:52:55 +0100
> 1. It can place the placeholder in the //Status/Reference 
> node if it has a sibling of Command=Add but I cannot figure 
> out a way of adding an index number to the placeholder that 
> increases sequentially for each match. Both
> position() and <xsl:number > do not work with the transform 
> constructed this way.

<xsl:number level="any" 
  count="Body/Status/Reference[preceding-sibling::Command='Add']"/>

should do the trick.

> 
> 2. How can I use the same placeholder in the 
> //Map/MapItem/Target/Loc if infact the number matches the one 
> in the //Status/Reference tag above it.

<xsl:template match="Map/MapItem/Target/Loc">
 <xsl:choose>
   <xsl:when test=". = ../../../preceding-sibling::Status[1]/Reference">
     <xsl:text>ref</xsl:text>
     <xsl:for-each select =
"../../../preceding-sibling::Status[1]/Reference">
        <xsl:number level="any" 
  count="Body/Status/Reference[preceding-sibling::Command='Add']"/>
     </
   </
   <xsl:otherwise> ??? (you don't say) </xsl:otherwise>
  </
</

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread