1 つの XSLT ファイル内で、最初に 1 つの XML ファイルを開き、子を持つ要素を抽出してから、その要素を 2 番目の XML ファイルに詰め込む方法はありますか?
1 つの XSLT で実行できない場合、言語の選択は vb スクリプトになります。
ここでさまざまな例を見てきましたが、混乱しているだけで、それらの大部分を理解していません。
XML1からノードを抽出するために私が取り組んでいるXSLは次のとおりです。
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output
method="xml"
omit-xml-declaration="yes"
indent="yes"
encoding="ISO-8859-1"/>
<xsl:template match="/">
<xsl:copy-of select="root/Collection/Item/." />
</xsl:template>
</xsl:stylesheet>
結果のアイテムを取得し、同じ XPATH のルート/コレクションで XML2 に追加したいと考えています。
この回答から、XML を memvar に返す vb スクリプトがあります。
XML1:
<root>
<collection1>
<item attr1, attr2...> ---this is what I am getting
<more>
</more>
</item>
<collection1>
<collection2>
<item attr1, attr2...>
<more>
</more>
</item>
<collection2>
...
<collection_n>
<item attr1, attr2...>
<more>
</more>
</item>
<collection_n>
</root>
XML2:
<root>
<collection1>
<item attr1, attr2...>
<more>
</more>
</item>
---- i want to insert node from XML1 here, only in collection1
<collection1>
<collection2>
<item attr1, attr2...>
<more>
</more>
</item>
<collection2>
...
<collection_n>
<item attr1, attr2...>
<more>
</more>
</item>
<collection_n>
</root>
したがって、新しい XML2:
<root>
<collection1>
<item attr1, attr2...>
<more>
</more>
</item>
<item attr1, attr2...>
<more>
</more>
</item>
<collection1>
<collection2>
<item attr1, attr2...>
<more>
</more>
</item>
<collection2>
...
<collection_n>
<item attr1, attr2...>
<more>
</more>
</item>
<collection_n>
</root>