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

RE: problems with nested templates

Subject: RE: problems with nested templates
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Fri, 27 Sep 2002 14:43:17 +0100
nested template not working
I call this problem "positional grouping".

There are two solutions. One is to treat it as a value-based grouping
problem, using the generate-id() of the node that starts each group as
the grouping key.

The other is the "anchored sibling" construct:

following-sibling::y[generate-id(preceding-sibling::x[1]) = $anchor]

which finds all the following sibling nodes provided that their most
recent X is the anchor node.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Christian Timmerer (ITEC)
> Sent: 27 September 2002 13:41
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  problems with nested templates
> 
> 
>  
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> hi all,
>   i have some problems when creating a hierarchy of elements 
> from a flat structure ... assume we have following xml 
> fragment (note that inside the B's and C's are also some 
> elements which content should be copied to the result tree. 
> there it will become an attribute and not an element):
> 
> the numbers are help entries and not part of the xml file
> 
> <A>
>   <B>...</B>	0
>   <C>...</C>	1
>   <C>...</C>	2
>   <C>...</C>	3
>   <C>...</C>	4
>   <C>...</C>	5
>   <C>...</C>	6
>   <C>...</C>	7
>   <C>...</C>	8
>   <C>...</C>	9
>   ...
> </A>
> 
> der result should look like this:
>  - the root element is nearly the same
>  - B will be copied to B1 ... no problem (line 0 from above)
>  - C (line 1) to C1 (no hierarchy needed - also not the problem)
>  - C (line 2) here i'm beginning to introduce the hierarchy
> 	the C's (line 2, 3, 4) should be as shown below (the 
> first element containing inside C1's ... and so on
> 
> <A1>
>   <B1>...</B1>
>   <C1>...</C1>
>   <C1>
> 	<C1>...</C1>
> 	<C1>...</C1>
> 	<C1>...</C1>
>   </C1>
>   <C1>...</C1>
>   <C1>...</C1>
>   <C1>...</C1>
>   <C1>
> 	<C1>...</C1>
> 	<C1>...</C1>
>   </C1>
>   <C1>...</C1>
>   ...
> </A1>
> 
> for achieving this i use <xsl:apply-templates
> select="following-sibling::C[position() &lt; $someValue]/>
> 
> the problem is that i found the same elements copied into the 
> hierarchy after the element where the hierarchy structure 
> begins. how can i skip this elements? the number of element 
> inside one hierarchy structure differs and will be controlled 
> by another xml document which i include with the document() function.
> 
> i've also tried an iterative approach, but there i can't use the
> position() function which i need to determine where the 
> nested structure begins ...
> 
> any hint/help would be appreciated
> 
> best regards
>  christian
> 
> 
> ps: the complete structure is rather extensive to post it in 
> the forum ;-)
> 
> -----BEGIN PGP SIGNATURE-----
> Version: PGP 7.0.4
> 
> iQA/AwUBPZRR7FGdEpLWuz2sEQJpNQCgu78q8q+hfUmLIJShNIbL7h7z8AkAnik9
> +GugaigK6RkUxEpIlPZYrUzp
> =8WV3
> -----END PGP SIGNATURE-----
> 
> 
>  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.