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

RE: [recursion pattern] sophisticated problem

Subject: RE: [recursion pattern] sophisticated problem
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Wed, 17 Sep 2003 04:43:10 +0100
recursion problems
You are trying to create one node in the output (X) corresponding to two
nodes in the input (C and D). I classify all such problems as grouping
problems, though this might be a rather simple one (but that depends on
whether the range of possible inputs you need to deal with can be
correctly inferred from your example).

The basic approach is that you need to fire one template rule that
processes the group as a whole. The solution might look like this:

<xsl:template match="C">
<X>
  <xsl:copy-of select="."/>
  <xsl:copy-of select="following-sibling::D[1]"/>
</X>
</xsl:template>

<xsl:template match="D"/>

Michael Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Romeo Disca
> Sent: 16 September 2003 16:36
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  [recursion pattern] sophisticated problem
> 
> 
> Hi,
> 
> I'm trying to find a solution for copying an existing tree 
> with an identity transformation. Some nodes should be 
> modified. For the most tasks I have a solution but this one.
> 
> Transforming a node like this:
> ----------------
> input tree:
> /context-node/
> 	+-/ A /
> 	+-/ B /
> 	+-/ C mode="x" /
> 	+-/ D mode="x" /
> 	+-/ E /
> 	+-/ F /
> -----------------
> result tree:
> /context-node/
> 	+-/ A /
> 	+-/ B /
> 	+-/ X /
> 		+-/ C mode="x" /
> 		+-/ D mode="x" /
> 	+-/ E /
> 	+-/ F /
> ===========
> 
> My approach uses the recursion pattern (Kay 2001 p. 614) to 
> iterate through the child node list. The best I've got so far is:
> -----------------
> result tree:
> /context-node/
> 	+-/ A /
> 	+-/ B /
> 	+-/ X /
> 		+-/ C mode="x" /
> 		+-/ D mode="x" /
> 		+-/ E /
> 		+-/ F /
> ===========
> 
> I think this is so because the recursion levels lay upon each 
> other and inserting the X node in one effects the rest node 
> list even if I test for 'not mode' Nodes.
> 
> Question: Is the recursion pattern the best way to do the job 
> and I only need to do more reasoning? Or, does anyone know an 
> alternative way to do that?
> 
> Romeo
> 
> 
> -- 
> Romeo Disca
> Email: romeo.disca@xxxxxxxxxxx
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.