指向性メモ::2004-07-08::カレントノードリスト

ページ情報
制作日
2004-07-08T02:58:30+09:00
最終更新日
2004-07-08T02:58:30+09:00
ページ内目次

ソート済みのカレントノードリストを表現するパターンが無いのは結構致命的かも知れない。xsl:for-each内で「1個まえに処理したノードと比べてみよう」と思った場合、どうにもならない。

$fooはノード集合として、1つ前に処理されたノードを変数に代入しようと思うと次のようになってしまう。XSLTにはグローバル宣言がないのでxsl:for-eachから出た時点で変数のスコープから外れてしまう。

<xsl:for-each select="$foo">
    <xsl:sort select="." order="ascending"/>
    <xsl:variable name="position" select="position()"/>
    <xsl:for-each select="$foo">
        <xsl:sort select="." order="ascending"/>
        <xsl:if test="position() = 1">
           <xsl:variable name="preceding" select="$foo[position() = $position - 1]"/>
        </xsl:if>
    </xsl:for-each><!-- この時点で$precedingは無効 -->
    <!-- 実際の処理 -->
</xsl:for-each>

preceding-sibling軸はカレントノードリストとは関係ないのでこの文脈では使うことが出来ない。

Comments

Trackbacks

Trackback Ping URI

http://yudai.arielworks.com/memo/2004/07/08/025830.trackback

末尾に「0 + 1」の計算結果を繋げて下さい。例えば計算結果が「17」の場合、「025830.trackback17」です。これは機械的なトラックバックスパムを防止するための措置です。

Post a comment

Name (optional)
Email address or URI (optional)
Do the math below (required to filter comment spams)
0 + 1 + 3 =
Message (required)
Submit
連絡先、リンク、転載や複製などについては『サイト案内』をご覧ください。Powered by HIMMEL

I ♥ Validator