Re(2): [xsl] adding namespaces to result [XSLT 1.0]

Subject: Re(2): [xsl] adding namespaces to result [XSLT 1.0]
From: "Fidalgo Sicilia Manuel" <manuel.fidalgo@xxxxxxxxxxxxxxx>
Date: 10 Nov 2006 08:36:00 +0100
Hi, thanks for the reply. This is the code:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xbrli="";
xmlns:xsl=""; >
  <xsl:template match="/">
       <xsl:element name="namespaces">
              <xsl:variable name="ns" select="/xbrli:xbrl/namespace::*"/>
              <xsl:copy-of select="$ns"/>

<?xml version="1.0" encoding="UTF-8"?>
<xbrli:xbrl xmlns:xbrli="";
xmlns:link=""; xmlns:xlink="http://www.w3.
org/1999/xlink"  xmlns:iso4217="";

-------OUTPUT when I apply XSL to XML------
<?xml version="1.0" encoding="UTF-8"?>
<namespaces iso4217=""; link="http://www.xbrl.
org/2003/linkbase" xbrli="";
xlink="http://www." xml="";

It writes the namespaces in the output but the problem is that these
dont have  xmlns: before the namespace prefix. I want these namespaces
the same as in the XML.

Thank you

Michael Kay  (08/11/2006  19:02):
>If the element name, the namespace prefix, and the namespace URI are all
>known to you at the time you write the stylesheet, then all you need to do
>is to use a literal result element:
><myElement xmlns:iso4217="";>
>  ....
>If any of these are not known in advance, then you have to use the technique
>you refer to, of copying a namespace node from another document. You've
>clearly misunderstood how this technique works, but it would be useful to
>see your code so that we can see which part of it you didn't understand.
>Michael Kay
>> Im trying to create a XML document from another using XSLT.
>> The problem comes when I try to add a namespace to the result
>> (e.g. xmlns:iso4217="http://www.
>>"). I have read in post http://www.stylusstudio.
>> com/xsllist/200504/post00350.html that it is not possible to
>> add a namespace with a xsl:attribute, so I tried to use
>> xsl:copy-of with the axe "namespace".
>> This doesnt work fine since it does not add "xmlns:" to the
>> namespace and if I try to add "xmlns:" by hand it does not
>> work because it stops from being an attribute. What can I do?
>> Thanks in advance

Current Thread