Re: [xsl] A grouping question ?

Subject: Re: [xsl] A grouping question ?
From: Richard Lewis <richard.lewis@xxxxxxxxx>
Date: Fri, 31 Oct 2003 15:18:55 +0000
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 

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:


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">
		<xsl:if test="../@bullet='true'">&bullet-char;</xsl:if>
		<xsl:apply-templates />

Sorry for being so stupid!!


 XSL-List info and archive:

Current Thread