[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] following-sibling in for-each


Subject: Re: [xsl] following-sibling in for-each
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 16 Nov 2001 16:01:47 +0000

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



Current Thread
Keywords