[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XSLT recursion problem
Hi Paolo, Le mercredi 28 septembre 2005 ` 09:46 +0200, Paolo Vaccari a icrit : > The real problem is that I don't want to have to know anything about > <sometag>. That is, I would be free to use (and nest!) whatever > non-proprietary tag inside my <repeat>, without modifing it. > Probably there's no way in XSLT 1.0 (if it is, why creating tunnel in > 2.0 ;) , but if you see another solution... You can do that in XSLT 1.0 using modes and a node-set extension: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:ax="http://dyomedea.com" xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl"> <xsl:template match="*|@*"> <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="ax:repeat" name="ax:repeat"> <xsl:param name="index">1</xsl:param> <xsl:variable name="rtf"> <xsl:apply-templates mode="ax:repeat"> <xsl:with-param name="index" select="$index"/> </xsl:apply-templates> </xsl:variable> <xsl:apply-templates select="exsl:node-set($rtf)/*"/> <xsl:if test="$index < count(*/ax:items[1]/ax:item)"> <xsl:call-template name="ax:repeat"> <xsl:with-param name="index" select="$index + 1"/> </xsl:call-template> </xsl:if> </xsl:template> <xsl:template match="ax:items"> <xsl:element name="{@element}"> <xsl:apply-templates select="ax:item[1]"/> </xsl:element> </xsl:template> <xsl:template match="ax:item"> <xsl:attribute name="src"> <xsl:value-of select="@src"/> </xsl:attribute> </xsl:template> <xsl:template match="*|@*" mode="ax:repeat"> <xsl:param name="index"/> <xsl:copy> <xsl:apply-templates select="@*|node()" mode="ax:repeat"> <xsl:with-param name="index" select="$index"/> </xsl:apply-templates> </xsl:copy> </xsl:template> <xsl:template match="ax:items" mode="ax:repeat"> <xsl:param name="index"/> <xsl:copy> <xsl:apply-templates select="@*|ax:item[$index]" mode="ax:repeat"> <xsl:with-param name="index" select="$index"/> </xsl:apply-templates> </xsl:copy> </xsl:template> </xsl:stylesheet> Eric -- Le premier annuaire des apiculteurs 100% XML! http://apiculteurs.info/ ------------------------------------------------------------------------ Eric van der Vlist http://xmlfr.org http://dyomedea.com (ISO) RELAX NG ISBN:0-596-00421-4 http://oreilly.com/catalog/relax (W3C) XML Schema ISBN:0-596-00252-1 http://oreilly.com/catalog/xmlschema ------------------------------------------------------------------------
|
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
|