XMLファイルから '(シングルクォート)と#を削除します。私はすべてのXMLノードをチェックする必要があります。私はすでに他のデータ抽出を行っているXSLTテンプレートを持っています。だから私は同じXSLTで別のテンプレートを作成することはできません。また、私はすべてのノードでtranslate関数を呼び出す必要はありません。すべてのノードで翻訳機能を適用する簡単な方法はありますか?最初のテンプレートが抽出され、2番目のテンプレートがデータを変換する同じXSLTで2つのテンプレートを適用できますか?新しいTempleteを作成せずにXSLTを使用して、すべてのXMLノードから#文字を削除します
誰かが私を助けることができますか? XMLサンプル:
<Report>
<ResCountryCode>US</ResCountryCode>
<Reporting>
<TIN>
<TaxIDNo>12456-451</TaxIDNo>
<TINCountryCode>US</TINCountryCode>
</TIN>
<TIN>
<TaxIDNo>4454-8754-4</TaxIDNo>
<TINCountryCode>US</TINCountryCode>
</TIN>
<OrganizationName>AB'C Ca'r Limi#ted</OrganizationName>
....
....(other nodes with same ' and # character)
</Reporting>
</Report>
XSLTサンプル:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
<xsl:template match="Report">
<Finance>
<Reporting>
<xsl:element name="ResCode">
<xsl:value-of select="ResCountryCode" />
</xsl:element>
<xsl:for-each select="Reporting/TIN">
<xsl:element name="TIN">
<xsl:attribute name="issuedBy">
<xsl:value-of select="TINCountryCode" />
</xsl:attribute>
<xsl:value-of select="TaxIDNo" />
</xsl:element>
</xsl:for-each>
<xsl:element name="Name">
<xsl:value-of select="Reporting/OrganizationName" />
</xsl:element>
</Reporting>
</Finance>
</xsl:template>
出力:
<Report>
<Finance>
<ResCountryCode>US</ResCountryCode>
<Reporting>
<sfa:TIN issuedBy="US">12456-451</sfa:TIN>
<sfa:TIN issuedBy="US">4454-8754-4</sfa:TIN>
<Name>AB'C Ca'r Limi#ted</Name>
....
....
</Reporting>
</Finance>
</Report>
予想される出力:
<Report>
<Finance>
<ResCountryCode>US</ResCountryCode>
<Reporting>
<sfa:TIN issuedBy="US">12456-451</sfa:TIN>
<sfa:TIN issuedBy="US">4454-8754-4</sfa:TIN>
<Name>ABC Car Limited</Name>
....
....(with out ' and #)
</Reporting>
</Finance>
</Report>
こんにちはTim、ありがとうございました。それは完璧に機能します。 – Shuvra