名前空間の操作に問題があります。
以下のように入力を取得します。
<?xml version="1.0" encoding="UTF-8"?>
<Org xmlns="http://mysample.org" >
<Dept>
<Person>
<FirstName>Sample </FirstName>
<LastName> Sampel L </LastName>
<Address>
<Street>Sample Street</Street>
<House>45 Block C </House>
<State>Kentucky</State>
<AddExtension>
<ns3:LandMark xmlns:ns3="http://mysample.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns3:POI tag="temp">Sample POI </ns3:POI>
</ns3:LandMark>
</AddExtension>
</Person>
</Dept>
</Org>
この XML のすべての要素に名前空間プレフィックスを追加する必要があります。
以下の XSL を試しました。
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns3="http://mysample.org">
<xsl:output omit-xml-declaration="no" indent="yes" />
<xsl:strip-space elements="*" />
<!-- <xsl:template match="*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/>
</xsl:copy> </xsl:template> -->
<xsl:template match="*">
<xsl:element name="ns3:{name()}" namespace="http://mysample.org">
<xsl:copy-of select="@*"></xsl:copy-of>
<xsl:copy-of select="namespace::*" />
<xsl:apply-templates select="node()" />
</xsl:element>
</xsl:template>
</xsl:stylesheet>
しかし、入力 XML の AddExtension データが原因で問題が発生しています」
注: 「AddExtension」内のデータは、スキーマに従って xsd:any タグに基づいています。したがって、入力 XML ごとに異なるデータになります。
どうすればこれを克服できますか?
助けてください。