基本的に私は現在3つの異なるXMLのために働く3つの別々のXSLTを持っています。その代わりに、特定のXSLTを実行し、結果として整形式のXMLを取得するために、特定の受信者の基盤を決定できる単一のXSLTが必要です。XSLT内で別のXSLTを実行するにはどうすればよいですか?
私は、次の方法使用してみました -
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:choose>
<xsl:when test="fruits/apples">
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<data>
<doc api_type="2" key="20" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:custom="urn:custom.com" ">
<custom:DataSet xyt1:type="tdc:somedataset">
<custom:some_table>
<custom:anothertable>
<xyt1:key>
<xyt1:fruitqty>
<xsl:value-of select="fruit/apple"/>
</xyt1:fruitqty>
</xyt1:key>
<end of this xslt>
</xsl:when>
<xsl:when test="vegetables/tomatoes">
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<data>
<doc api_type="3" key="100" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:custom="urn:custom.com" ">
<custom:DataSet xyt1:type="tdc:somedataset2">
<custom:some_table2>
<custom:anothertable2>
<xyt1:fruitqty>
<xsl:value-of select="fruit/oranges"/>
</xyt1:fruitqty>
<end of this xslt2>
</xsl:when>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
を、私はこのような二つの異なるXMLファイルを取得します -
ファイル1 -
<fruits>
<apple>2</apple>
</fruits>
ファイル2 -
<vegetables>
<tomatoes>2</tomatoes>
</vegetables>
だからフルーツ/リンゴが見つかったら最初のxsltを実行し、野菜/トマトはもう一方を実行したい。
正確に入力XMLノードに基づいて、個々の作業ファイルがある特定のXSLTを実行したいが、すべてを1つのXSLTに入れたい。
このメソッドは正しいブロック内にありますが、「ノード」のいずれも出力していません。単にXML内の値を出力しています。例えばのために
.- それはちょうど私が正しくフォーマットされたXMLを取得することはできません結果としてリンゴやない<xyt1:fruitqty> 2 </xyt1:fruitqty>.
のようなノードに対して「2」を示しています。どのようにこの権利を取得するための任意のアイデア?
を確認してください:[MCVE]答えのための –