質問
こんにちは、FPML 4のXMLファイルをFPML 5に変換しようとしています。
私が変更しなければならない唯一のことは、ここのFPMLヘッダーが例に従うことです。
入力ファイルFPML 4
<FpML version="4-0" xsi:type="DataDocument" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.fpml.org/2003/FpML-4-0 ../fpml-main-4-0.xsd" xmlns="http://www.fpml.org/2003/FpML-4-0">
<trade>...</trade>
<party id="partyA">...</party>
<party id="partyB">...</party>
</FpML>
これで、結果のファイルは次のようになります。
<dataDocument xmlns="http://www.fpml.org/FpML-5/confirmation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" fpmlVersion="5-0" xsi:schemaLocation="http://www.fpml.org/FpML-5/confirmation ../../fpml-main-5-0.xsd">
<trade>...</trade>
<party id="partyA">...</party>
<party id="partyB">...</party>
</dataDocument>
XSLチュートリアルを試してみましたが、何も助けになりませんでした。誰でも大歓迎です。
@アップデート:
今のところそれが機能しているのを見るために私はこのXSLを試しました
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<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:template match="FpML">
<xsl:element name="test">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
ありがとう
解決
このスタイルシート:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fpml4="http://www.fpml.org/2003/FpML-4-0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.fpml.org/FpML-5/confirmation"
exclude-result-prefixes="fpml4">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="fpml4:FpML">
<dataDocument fpmlVersion="5-0"
xsi:schemaLocation=
"http://www.fpml.org/FpML-5/confirmation ../../fpml-main-5-0.xsd">
<xsl:apply-templates select="node()"/>
</dataDocument>
</xsl:template>
<xsl:template match="fpml4:*">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
出力:
<dataDocument fpmlVersion="5-0"
xsi:schemaLocation="http://www.fpml.org/FpML-5/confirmation ../../fpml-main-5-0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.fpml.org/FpML-5/confirmation">
<trade>...</trade>
<party id="partyA">...</party>
<party id="partyB">...</party>
</dataDocument>
編集: :デフォルトの名前空間でより良い...
他のヒント
これが、あなたが求めた入力サンプルの変更を行うサンプルスタイルシートです。
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fpml4="http://www.fpml.org/2003/FpML-4-0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.fpml.org/FpML-5/confirmation"
exclude-result-prefixes="fpml4"
version="1.0">
<xsl:template match="fpml4:*">
<xsl:element name="{name()}">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="fpml4:FpML">
<dataDocument fpmlVersion="5-0" xsi:schemaLocation="http://www.fpml.org/FpML-5/confirmation ../../fpml-main-5-0.xsd">
<xsl:apply-templates/>
</dataDocument>
</xsl:template>
<xsl:template match="@* | text() | comment() | processing-instruction()">
<xsl:copy/>
</xsl:template>
</xsl:stylesheet>
このような単純な変換が、私がまったくチェックしていないスキーマを満たすのに十分であるかどうか。
所属していません StackOverflow