指向性メモ::2004-07-07::それにしてもRTFはわかりにくい

ページ情報
制作日
2004-07-07T09:52:18+09:00
最終更新日
2004-07-07T09:52:18+09:00
ページ内目次

W3Cの勧告文にはわかりやすい例がないのだが、変数を作る場合select属性を使った場合とテンプレートとして書いた場合では結果が違う。

例えば、document()関数を使って

<xsl:param name="foo" select="document('hoge.xml')"/>

と書くと$fooにはノード集合が格納される。

If the variable-binding element has a select attribute, then the value of the attribute must be an expression and the value of the variable is the object that results from evaluating the xpression. In this case, the content must be empty.

上記のようにselect属性が有る場合は式を評価した結果のオブジェクト(この場合はノード集合)が格納される。

xsl:paramもしくはxml:variableの内容としてテンプレートを書いた場合は結果ツリーフラグメントが格納される。

<xsl:param name="bar">
    <xsl:copy-of select="document('hoge.xml')"/>
</xsl:param>

それぞれの変数はデータ型が違うのでその後の処理で使う場合は注意が必要になる。

<!-- これは問題ない -->
<xsl:apply-templates select="$foo"/>

<!-- これはエラー -->
<xsl:apply-templates select="$bar"/>

Comments

Trackbacks

Trackback Ping URI

http://yudai.arielworks.com/memo/2004/07/07/095218.trackback

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

Post a comment

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

I ♥ Validator