Re: [xsl] A grouping question ?

Subject: Re: [xsl] A grouping question ?
From: Mukul Gandhi <mukulgw3@xxxxxxxxx>
Date: Sat, 1 Nov 2003 20:21:34 -0800 (PST)
Hi Emilio,

Here is another XSL, solving the problem --

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:xalan="http://xml.apache.org/xalan";>
<xsl:output method="html" version="1.0"
encoding="UTF-8" indent="yes"/>
<xsl:template match="/Content">
  <html>
    <xsl:for-each select="Paragraph">
	<xsl:if test="@bullet = 'false'">
	  <p>
	    <xsl:value-of select="Text/@txt"/>
  	  </p>
        </xsl:if>
	<xsl:if test="((@bullet = 'true') and
(preceding-sibling::Paragraph[1][@bullet = 'false']))
">
	   <ul>
	     <li>
		<xsl:value-of select="Text/@txt"/>
	     </li>
	     <xsl:call-template name="print-li-tags">
		 <xsl:with-param name="xml-subset"
select="following-sibling::Paragraph"/>
	     </xsl:call-template>
	   </ul>
         </xsl:if>
      </xsl:for-each>
  </html>	
</xsl:template>
	
<xsl:template name="print-li-tags">
   <xsl:param name="xml-subset"/>
     <xsl:if test="$xml-subset[1][@bullet = 'true']">
       <li>
	  <xsl:value-of select="$xml-subset[1]/Text/@txt"/>
       </li>
     </xsl:if>

     <xsl:variable name="ns">
	<xsl:for-each select="$xml-subset[position() &gt;
1]">
	   <Paragraph bullet="{@bullet}">
	      <xsl:value-of
select="xml-subset[1]/Text/@txt"/>
            </Paragraph>
 	</xsl:for-each>
     </xsl:variable>
		
     <xsl:for-each
select="xalan:nodeset($ns)/Parapgarh">
	<xsl:if test="(position() = 1) and (@bullet =
'false')">
	  <p>
	    <xsl:value-of select="Text/@txt"/>
	  </p>
	  <xsl:call-template name="print-li-tags">
	    <xsl:with-param name="xml-subset"
select="xalan:nodeset($ns)/Paragraph[position() &gt;
1]"/>
	  </xsl:call-template>
        </xsl:if>
      </xsl:for-each>
	
   </xsl:template>
</xsl:stylesheet>


Regards,
Mukul

--- Emilio_Gustavo_Ormeño <eormeno@xxxxxxxxxxxxxxxxx>
wrote:
> 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
> 


__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/

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


Current Thread