RE: [xsl] problems with nested templates

Subject: RE: [xsl] problems with nested templates
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Fri, 27 Sep 2002 14:43:17 +0100
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: [xsl] 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