グーグルで答えを探してみましたが、返される結果は、文字列を置き換える方法か、部分文字列を置き換える方法などです。しかし、私の質問は少し異なります。
「data/records / record」を処理する既存のXSLテンプレート、たとえば「hello-world 」があるが、 hello-worldを変更できないため、データをマッサージ/変更するラッパーテンプレートを作成することを考えています。hello-worldに渡す前に各レコード内に...それを行う方法はありますか?
これまで、重複レコードを除外する関数を作成してきましたが、「data / records/*」内のすべてのレコードを新しいものに置き換えることを考えていました...
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:call-template name="get-unique-record">
<xsl:with-param name="records" select="/data/records/record"/>
</xsl:call-template>
</xsl:template>
<!-- This function will filter out the given records and return a unique set of records -->
<xsl:key name="kField_ID" match="field[@name='ID']" use="."/>
<xsl:template name="get-unique-record">
<xsl:param name="records"/>
<xsl:for-each select="$records">
<xsl:variable name="record" select="."/>
<xsl:if test="$record//field[generate-id() = generate-id(key('kField_ID', .))]">
<xsl:copy-of select="$record"/>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
今...次のようなことを行うことは可能ですか?
<xsl:variable name="/data/records/record">
<xsl:call-template name="get-unique-record">
<xsl:with-param name="records" select="/data/records/record"/>
</xsl:call-template>
</xsl:variable>
編集:@LasrH、迅速な返信をありがとう。既存の「/」のコピーを作成してから、すべての/ data / records / recordをフィルター処理されたものに置き換える方法はありますか?
EDIT2:@LasrH、「データ」ノードを変更および再構築するためのテンプレートをいくつか作成しました。node-setを使用して、既存の入力を入力としての新しいデータに「置き換える」ことはできますか?
<xsl:variable name="data">
<xsl:call-template name="rebuild-data-with-record">
<xsl:with-param name="records">
<xsl:copy-of select="$unique-records"></xsl:copy-of>
</xsl:with-param>
</xsl:call-template>
</xsl:variable>
次に、さらに下の方で、次のようなノードセットを使用しようとしました。
<xsl:apply-templates select="exslt:node-set($data)/data"/>
しかし、それを実行しているようには見えません...エラーもスローされません。