[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 15:18:55 +0000
html bullet
On Friday 31 Oct 2003 13:55, Richard Lewis wrote:
>
> 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>
>
Oh, no - hang on, that won't work at all, will it! The nesting is all 
overlapped!!

I think the problem here is the structure of the XML document.

<ul> tags in HTML are designed to designate document structure and the 
attributes in your XML seem to be suggesting the same sort of structure.

But you can't use attributes to design document structure - you need to use 
the structure of the node tree:

<content>
	<para>
		<text>...</text>
	</para>
	<para>
		<text>...</text>
		<text>...</text>
	</para>
	<para>
		<text>...</text>
	</para>
</content>

The other thing you could do is to format all <text> elements as <p>s and 
manually insert a bullet where you want one:

<xsl:template match="text">
	<p>
		<xsl:if test="../@bullet='true'">&bullet-char;</xsl:if>
		<xsl:apply-templates />
	</p>
</xsl:template>

Sorry for being so stupid!!

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.