結果ツリーフラグメントの誤解
2004年12月の指向性メモ で言及されてるのを読んでもう一度仕様書を読み直してみる。
Variables introduce an additional data-type into the expression language. This additional data type is called result tree fragment. A variable may be bound to a result tree fragment instead of one of the four basic XPath data-types (string, number, boolean, node-set). A result tree fragment represents a fragment of the result tree. A result tree fragment is treated equivalently to a node-set that contains just a single root node. However, the operations permitted on a result tree fragment are a subset of those permitted on a node-set. An operation is permitted on a result tree fragment only if that operation would be permitted on a string (the operation on the string may involve first converting the string to a number or boolean). In particular, it is not permitted to use the
/,//, and[]operators on result tree fragments. When a permitted operation is performed on a result tree fragment, it is performed exactly as it would be on the equivalent node-set.
強調した部分が重要らしい。最初の強調がややこしい。原文引用なのは訳文がまたさらにややこしいから (謎)
結果ツリーフラグメントに使える操作はノード集合の一部 (最初の強調) でその許される操作ってのは文字列にできるやつだけ (二つ目の強調)。あとはその後に書いてある通り、/ とかの演算子は使えない。
結局、結果ツリーフラグメントが格納されている $rtf がある場合において <xsl:apply-templates select="$rtf/child::node()"/> は XSLT1.0 的にはエラーらしい。
そんなこんなで、XSLT1.0 でマトモな変換を書こうとするとかなり冗長なことをせざるを得ない状況が生まれるみたいです。めんどくさー
関係ないけど、どういう経緯でこういう制限がついたんだろう。
関連エントリー
- New version of $X コピペメモ 今までの $X は evaluate を二回する問題があってダサいので、使い勝手をそのままにしつつ新しくして使いはじめました。 ...
- XPath1.0 いろいろ一覧 last(), number position(), number count(node-set), number id(obj), num...
- MCD-ST Liberty SW License Agreement V2 はフリーなライセンスか? STM32CubeMX でジェネレートされるコードは MCD-ST Liberty SW License Agreement V2 というラ...
- textarea.value は代入すると値が変わる 以下のような挙動をする。 var textarea = document.createElement('textarea'); textar...
- Sierra にしたらリモートの日本語が化けるようになった 以下のような環境で日本語が化けるようになった。 macOS Sierra リモートで screen を使っている ssh host -t s...