グローバル変数は、さまざまな種類の要素ごとに、処理する必要のある属性を示します。
<xsl:variable name="attributes.rtf">
<element name="measure">
<att>type</att>
<att>quantity</att>
<att>unit</att>
</element>
<element name="milestone">
<att>n</att>
</element>
<element name="lb">
<att>ed</att>
<att>type</att>
<att>subtype</att>
<att>n</att>
</element>
</xsl:variable>
<xsl:variable name="attributes" select="exslt:node-set($attributes.rtf)" /> <!-- This is XSLT 1.0 -->
コンテキストが要素である場合、その種類の要素の属性をループするfor-eachが必要です。1つのXPath式でこれを行う方法がわかりません。今私はこれらの2つを持っています:
<xsl:variable name="temp" select="." /> <!-- For, say, a <measure> element, -->
<xsl:for-each select="$attributes/element[@name=name($temp)]/att"> <!-- loop through the names "type", "quantity", and "unit" -->
<xsl:for-each select="$temp/@*[name()=current()]"> <!-- If an attribute of that name exists in the current <measure> element -->
<!-- (now stored as $temp), then process that attribute. -->
</xsl:for-each>
</xsl:for-each>
$ tempを作成せずに、1つの式でこれを行う方法はありますか?
ただし、コンテキスト要素にリストされている属性のいずれかが含まれているかどうかを示す外部テスト条件も必要です。そのテストのために、私は一つの表現が欲しいです。
(属性の処理は順序付けする必要があるため、2つのループが必要になる場合があります。ただし、順序はテスト条件には関係ありません。したがって、1つの式でそれを実行できる可能性があります。)