Re: [xsl] XSLT recursion problem

Subject: Re: [xsl] XSLT recursion problem
From: Ragulf Pickaxe <ragulf.pickaxe@xxxxxxxxx>
Date: Wed, 28 Sep 2005 10:29:30 +0200
> 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...

Hi again Paolo,

Why can you not have a general template for the "Sometag" and other
elements that you just want to pass on?

I think that your own solution would be able to provide, if you change
the template that matches "Sometag" to the following:

<xsl:template match="*">
 <xsl:param name="index" select="1"/>
   <xsl:copy-of select="@*"/>
     <xsl:with-param name="index" select="$index"/>
   <!-- sometag content -->

The match="ax:items" is more specific than match="*" and thus has
higher priority.

My solution, I think, you would have to change three templates:

<xsl:template match="ax:repeat">
 <xsl:apply-templates/> <!-- instead of <xsl:apply-templates

<xsl:template match="*"> <!-- Instead of <xsl:template match="sometag" -->
  <xsl:copy> <!-- Copy element (shallow copy) -->
    <xsl:copy-of select="@*"/> <!-- Copy all attributes -->
     <!-- other non-proprietary elements to be processed: -->
     <xsl:apply-templates select="*[not(self::ax:items)]"/>
     <!-- Propriotary elements to be processed: -->
     <xsl:apply-templates select="ax:items[1]" mode="first"/>

And remove the <sometag> and </sometag>from the
<xsl:template match="ax:items" mode="first">

Is this what you need?

Ragulf Pickaxe :-)

Current Thread