[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Iterating over values in a table of data
Hi,
Backwards from Andrew's answer: <input> <!-- This is a table of lookup values. --> <data> <item> <value>one</value> </item> <item> <value>two</value> </item> <item> <value>three</value> </item> </data> <!-- This node needs to be repeatedly transformed for each input data item --> <repeat> Item <value-of name="value"/> is in position <position-of name="value"/> </repeat> </input> <xsl:stylesheet ...> <xsl:variable name="repeater" select="/input/repeat"/> <xsl:template match="repeat"/> <!-- suppresses output on default traversal --> <xsl:template match="data"> <xsl:for-each select="item"> <xsl:apply-templates select="$repeater" mode="repeat"> <xsl:with-param name="item" select="."/> <xsl:with-param name="pos" select="position()"/> </xsl:apply-templates> </xsl:for-each> </xsl:template> <xsl:template match="repeat" mode="repeat"> <xsl:param name="item" select="/.."/> <xsl:param name="pos" select="0"/> <item> <xsl:apply-templates> <xsl:with-param name="item" select="$item"/> <xsl:with-param name="pos" select="position()"/> </xsl:apply-templates/> </item> </xsl:template> <xsl:template match="value-of"> <xsl:param name="item"/> <xsl:value-of select="$item"/> </xsl:template> <xsl:template match="position-of"> <xsl:param name="pos"/> <xsl:value-of select="$pos"/> </xsl:template> </xsl:stylesheet> Untested. Cheers, Wendell
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|