Hi Emilio,
This transformation:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="kList" match="Paragraph[(_at_)bullet='true']"
use="generate-id(preceding-sibling::Paragraph
[not(@bullet='true')][1]
)"/>
<xsl:template match="Content">
<html>
<xsl:apply-templates
select="node()[not(self::Paragraph and @bullet='true')]"/>
</html>
</xsl:template>
<xsl:template match="Paragraph[not(@bullet='true')]">
<p><xsl:value-of select="Text/@txt"/></p>
<xsl:if test="following-sibling::Paragraph
[(_at_)bullet='true']">
<ul>
<xsl:apply-templates
select="key('kList', generate-id())"/>
</ul>
</xsl:if>
</xsl:template>
<xsl:template match="Paragraph[(_at_)bullet='true']">
<li><xsl:value-of select="Text/@txt"/></li>
</xsl:template>
</xsl:stylesheet>
when aplied on your source.xml:
<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>
produces the wanted result:
<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>
Hope this helped.
=====
Cheers,
Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
"Emilio Gustavo Ormeño" <eormeno(_at_)iinfo(_dot_)unsj(_dot_)edu(_dot_)ar>
wrote in message
news:3FA256EB(_dot_)4050008(_at_)iinfo(_dot_)unsj(_dot_)edu(_dot_)ar(_dot_)(_dot_)(_dot_)
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