Hi Paolo,
Le mercredi 28 septembre 2005 à 09:46 +0200, Paolo Vaccari a écrit :
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="{(_at_)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
------------------------------------------------------------------------
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--