[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: Richard Lewis <richard.lewis@xxxxxxxxx>
Date: Fri, 31 Oct 2003 13:55:49 +0000
Re:  A grouping question ?
On Friday 31 Oct 2003 12:34, Emilio Gustavo Ormeño 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>

First, do you really need an element, 'Text' with an attribute, 'txt'? Why not 
just have <Text>...</Text>?

>
> 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>
>

Does this mean that you want to format 'Paragraph' elements where 
@bullet='true' as <li>s and 'Paragraph's where @bullet='false' as <p>s?

<xsl:for-each select="para">
	<xsl:if test="@bullet = 'true' and preceding-sibling::[1]\@bullet='false'">
		<ul>
	</xsl:if>
	<xsl:choose>
		<xsl:when test="@bullet = 'true'">
			<li><xsl:value-of select="text" /></li>
		</xsl:when>
		<xsl:otherwise>
			<p><xsl:value-of select="text" /></p>
		</xsl:otherwise>
	</xsl:choose>
	<xsl:if test="@bullet = 'true' and following-sibling::[1]\@bullet='false'">
		</ul>
	</xsl:if>
</xsl:for-each>

(Not tested!)

Cheers,
Richard


 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.