Hello
I have quite a strange problem with XSLT transformation, and I have no idea where even to start looking for a solution

:
In my input file I have something like:
Code:
<store xmlns:food="http://www.food-names">
<element type="food:chocolate">Fazer chocolate</item>
</store>
Let's say I want to transform "element" to "item". In my output file I then have
Code:
<store>
<item type="food:chocolate">Fazer chocolate</item>
</store>
The "
xmlns:food="http://www.food-names"" declaration is missing. Which is quite understandable, because formally this namespace is not referenced in the file at all. But, actually it IS referenced, but from INSIDE the "type" attribute VALUE - but this cannot be noticed by XSLT.. at least this is what I think the reason is.
My question is: How to force the XSLT sheet to include ALL namespace declarations that were there in the input file (even the "unused ones")? Or maybe there is some other solution to my problem?
Or maybe I understood the reason of my problem incorrectly.. ?
(If I add to my input file something like <element
food:type="chocolate">Fazer chocolate</item> the namespace IS included correctly. But I am working with already existing files and standards and I cannot adjust them. And without this namespace included, the output file is no longer correct for other tools that use it)
My XSLT part responsible for this transformation looks something like that:
Code:
<xsl:template match="/*"> <!-- matches root node-->
<xsl:element name="{name(.)}">
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>
<!-- copy all attributes -->
<xsl:template match="@*">
<xsl:copy-of select="."/>
</xsl:template>
<!-- copy all nodes -->
<xsl:template match="*">
<xsl:element name="{name()}" >
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>
Please help! Any ideas highly appreciated ;)