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: -----XSL------ <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:template match="/"> <xsl:element name="namespaces"> <xsl:variable name="ns" select="/xbrli:xbrl/namespace::*"/> <xsl:copy-of select="$ns"/> </xsl:element> </xsl:template> </xsl:stylesheet> -------------------------- -------XML------ <?xml version="1.0" encoding="UTF-8"?> <xbrli:xbrl xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:link="http://www.xbrl.org/2003/linkbase" xmlns:xlink="http://www.w3. org/1999/xlink" xmlns:iso4217="http://www.xbrl.org/2003/iso4217" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> </xbrli:xbrl> ------------------------- -------OUTPUT when I apply XSL to XML------ <?xml version="1.0" encoding="UTF-8"?> <namespaces iso4217="http://www.xbrl.org/2003/iso4217" link="http://www.xbrl. org/2003/linkbase" xbrli="http://www.xbrl.org/2003/instance" xlink="http://www. w3.org/1999/xlink" xml="http://www.w3.org/XML/1998/namespace" xsi="http://www. w3.org/2001/XMLSchema-instance"/> ---------------------------------------- It writes the namespaces in the output but the problem is that these namespaces dont have xmlns: before the namespace prefix. I want these namespaces exactly 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="http://www.xbrl.org/2003/iso4217"> > .... ></myElement> > >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 >http://www.saxonica.com/ > > >> >> 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. >> xbrl.org/2003/iso4217"). 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] adding namespaces to resu, Michael Kay | Thread | Re: [xsl] adding namespaces to resu, Florent Georges |
[xsl] Fwd: Merging XML files, Rodrigo Segnini | Date | RE: [xsl] Fwd: Merging XML files, Michael Kay |
Month |