How can I dynamically set the default namespace declaration of an XSLT transformation's output XML?
- by Paralife
I can do it, but not for the default namespace, using the <xsl:namespace>. If I try to do it for the default namespace:
<xsl:namespace name="" select"myUri"/>
it never works. It demands that I explicitly define the namespace of the element to be able to use the above null prefix declaration.
The reason I want this is because I have a task to transform an input XML file to another output xml. The output XML has many elements and i dont want to have to explicitly set the namespace for every element. Thats why I want to set the default and never bother again. But the default must be computed from some data in the source XML. It does not change during the whole transformation, but it is dependent on input XML data.
Any solution?
EDIT 1:
To sup up:
I want to create a namespace dynamically and set it to be the default namespace of the output xml document. The uri of the namespace is derived from some data in the input XML.
If I use <xsl:namespace> in my root output element, I cannot create a default namespace for it, only a prefixed one. And even with the prefixed one, it does not propagate to children.