Re: [xsl] Problems grouping adjacent siblings

Subject: Re: [xsl] Problems grouping adjacent siblings
From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx>
Date: Thu, 30 Jun 2005 01:06:17 -0700 (PDT)
Hi Roman,
  I thought the following stylesheet would have
worked.. But its not working. Its identity template
based ..

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
	
<xsl:output method="xml" indent="yes" />
	
<xsl:template match="node() | @*">
  <xsl:copy>
    <xsl:apply-templates select="node() | @*" />	   
  </xsl:copy>
</xsl:template>

<xsl:template match="exp">
  <xsl:if test="not(name(preceding-sibling::*[1]) =
'exp')">
    <remark>
      <xsl:copy-of select=". | following-sibling::exp"
/>
    </remark>
  </xsl:if>
</xsl:template>

</xsl:stylesheet>

Regards,
Mukul


--- Huditsch Roman <Roman.Huditsch@xxxxxxxxxxxxx>
wrote:

> Good morning list,
> 
> I would like to group adjacent siblings which share
> the same local-name
> into a container element.
> 
> Given this structure
> 
> <ax>
>   <e></e>
>   <r></r>
>   <exp>Example</exp>
>   <exp>bla bla</exp>
>   <exp>jada jada</exp>
>   <b></b>
>   <e></e>
>   <exp>Example 2</exp>
>   <exp>bla bla</exp>
>   <v></v>
> </ax>
> <bx>
>   <c></c>
>   <exp>Example 3</exp>
>   <exp>bla bla</exp>
>   <b></b>
> </bx>
> 
> The following output should be produced:
> 
> <ax>
>   <e></e>
>   <r></r>
>     <remark>
>   	<exp>Example</exp>
>   	<exp>bla bla</exp>
>   	<exp>jada jada</exp>
>     </remark>
>   <b></b>
>   <e></e>
>   <remark>
>     <exp>Example 2</exp>
>     <exp>bla bla</exp>
>   </remark>
>   <v></v>
> </ax>
> <bx>
>   <c></c>
>   <r></r>
>   <remark>  
>     <exp>Example 3</exp>
>     <exp>bla bla</exp>
>   </remark>
>   <b></b>
> </bx>
> 
> I thought that this would be the classical use-case
> for an
> <xsl:for-each-group> with @group-adjacent, but I am
> getting the
> strangest results...
> I don't even know if it is better to do the grouping
> in a template
> matching
> exp[not(preceding-sibling::*[1][local-name()='exp'])
> or in a template
> matching exp's parent
> I also tried to find a @group-starting-with
> solution, since the first
> <exp> always starts with the string 'Example'. But
> with no success
> either....
> Can you help me with this problem?
> Thank you very much for your help!
> 
> Wbr,
> Roman
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Current Thread