This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: following-sibling in for-each
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: "McNally, David" <David dot McNally at moodys dot com>
- Cc: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Date: Fri, 16 Nov 2001 16:01:47 +0000
- Subject: Re: [xsl] following-sibling in for-each
- Organization: Jeni Tennison Consulting Ltd
- References: <3475147EADCBD51199150002A52C17043E3C98@MDYNYCMSX5>
- Reply-to: xsl-list at lists dot mulberrytech dot com
David,
> This doesn't address the following-sibling ordering problem, and
> isn't very elegant, but I think it does what you want:
Not very elegant is one way of putting it. Completely contrary to the
processing model of XSLT is another :)
If you give people solutions using disable-output-escaping, you should
at least give them the warning that (a) they'll generate
non-well-formed XML/HTML if they're not very careful and (b)
processors are not required to support disable-output-escaping.
Having said that, it is true that the alternative that doesn't use
extensions or disable-output-escaping is pretty horrible:
<xsl:variable name="properties"
select="Property[starts-with(@SecurityType, '1')]" />
<table width="100%">
<xsl:for-each select="$properties">
<xsl:sort select="@TabOrder" data-type="number" />
<xsl:if test="position() mod 2 = 1">
<xsl:variable name="index" select="position()" />
<tr>
<td><xsl:value-of select="." /></td>
<td>
<xsl:for-each select="$properties">
<xsl:sort select="@TabOrder" data-type="number" />
<xsl:if test="position() = $index + 1">
<xsl:value-of select="." />
</xsl:if>
</xsl:for-each>
</td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list