XML から ONIX を作成しようとしています。XSL ファイルは次のとおりです。
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xlink="http://www.w3.org/1999/xlink" mediatype="application/xml">
<xsl:output method="xml" encoding="utf-8" />
<xsl:template match="books">
<xsl:variable name="SentDate"><xsl:value-of select="translate(@timestamp,'- :','')" /></xsl:variable>
<ONIXMessage xmlns="http://www.editeur.org/onix/2.1/reference">
<Header>
<FromCompany>MyCompany</FromCompany>
<ToCompany>Google Play</ToCompany>
<SentDate><xsl:value-of select="substring($SentDate,1,string-length($SentDate) - 2)" /></SentDate>
</Header>
<xsl:apply-templates />
</ONIXMessage>
</xsl:template>
<xsl:template match="books/book">
<Product>
<RecordReference><xsl:value-of select="@id" /></RecordReference>
</Product>
</xsl:template>
変換用の XML は次のとおりです。
<books xmlns:l="http://www.w3.org/1999/xlink" timestamp="2013-05-27 22:03:02">
<book id="1">...</book>
<book id="2">...</book>
<book id="3">...</book>
</books>
そして、ここに変換の結果があります:
<?xml version="1.0" encoding="utf-8"?>
<ONIXMessage xmlns="http://www.editeur.org/onix/2.1/reference" xmlns:xlink="http://www.w3.org/1999/xlink">
<Header>
<FromCompany>MyCompany</FromCompany>
<ToCompany>Google Play</ToCompany>
<SentDate>201305272203</SentDate>
</Header>
<Product xmlns="">
<RecordReference>1</RecordReference>
</Product>
<Product xmlns="">
<RecordReference>2</RecordReference>
</Product>
<Product xmlns="">
<RecordReference>3</RecordReference>
</Product>
</ONIXMessage>
問題は、すべての製品ノードでこれらのxmlns=""を取り除く方法です。前もって感謝します。