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

RE: A grouping question ?

Subject: RE: A grouping question ?
From: Américo Albuquerque <melinor@xxxxxxxx>
Date: Fri, 31 Oct 2003 22:49:29 -0000
group generate id
Hi

Try this stylesheet:
  <xsl:key match="Paragraph" name="group"
use="generate-id(preceding-sibling::Paragraph[@bullet='false'][1])"/>
  <xsl:template match="Content">
    <html>
      <xsl:apply-templates select="Paragraph[@bullet='false']"/>
    </html>
  </xsl:template>
  <xsl:template match="Paragraph">
    <p>
      <xsl:apply-templates/>
    </p>
    <xsl:if test="key('group',generate-id())[1]">
      <ul>
        <xsl:apply-templates mode="bullet"
select="key('group',generate-id())[@bullet='true']"/>
      </ul>
    </xsl:if>
  </xsl:template>
  <xsl:template match="Paragraph" mode="bullet">
    <li>
      <xsl:apply-templates/>
    </li>
  </xsl:template>
  <xsl:template match="Text">
    <xsl:value-of select="@txt"/>
  </xsl:template>

Regards,
Americo Albuquerque


> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Emilio Gustavo Ormeño
> Sent: Friday, October 31, 2003 12:35 PM
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  A grouping question ?
> 
> 
> Hi, I don't know if this is a grouping question, but given 
> than I don't 
> know the way to solve it. I need your help. This is my problem:
> 
> I have a XML file such as:
> 
> <Content>
>     <Paragraph bullet='false'>
>         <Text txt='Hello World'/>
>     </Paragraph>
>     <Paragraph bullet='true'>
>         <Text txt='First Bulleted Hello World'/>
>     </Paragraph>
>     <Paragraph bullet='true'>
>         <Text txt='Second Bulleted Hello World'/>
>     </Paragraph>
>     <Paragraph bullet='false'>
>         <Text txt='A normal line of text'/>
>     </Paragraph>
>     <Paragraph bullet='true'>
>         <Text txt='Another bulleted line'/>
>     </Paragraph>
>     <Paragraph bullet='true'>
>         <Text txt='A second bulleted line'/>
>     </Paragraph>
> </Content>   
> 
> And I want an HTML output like the following:
> 
> <html>
>     <p>Hello World</p>
>     <ul>
>         <li>First Bulleted Hello World</li>
>         <li>Second Bulleted Hello World</li>
>     </ul>
>     <p>A normal line of text</p>
>     <ul>
>         <li>Another bulleted line</li>
>         <li>A second bulleted line</li>
>     </ul>
> </html>
> 
> I thought that it was a grouping problem, but when I tried to 
> solve it, 
> I realized that this is not a "normal" grouping problem.
> 
> Can someone tell me a way to solve it -- if it exists....
> 
> Thanks
> Emilio
> 
> 
>  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.