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]\(_at_)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]\(_at_)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