[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XSLT recursion problem

Subject: Re: XSLT recursion problem
From: Ragulf Pickaxe <ragulf.pickaxe@xxxxxxxxx>
Date: Wed, 28 Sep 2005 10:29:30 +0200
xslt recursive copy
> 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>
   <xsl:copy-of select="@*"/>
   <xsl:apply-templates>
     <xsl:with-param name="index" select="$index"/>
   </xsl:apply-templates>
   <!-- sometag content -->
 </xsl:copy>
</xsl:template>

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
select="sometag"/>-->
</xsl:template>

<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"/>
  </xsl:copy>
</xsl:template>

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


Is this what you need?

Regards,
Ragulf Pickaxe :-)

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.