[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Default Namespace version problem


Subject: RE: [xsl] Default Namespace version problem
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Thu, 5 Dec 2002 10:20:23 -0000

I suspect that what's happening here is that your source document
contains an element with local name FOO in namespace V1, and you want
your result document to contain an element with local name FOO in
namespace V2. People sometimes imagine you can do this simply by
changing the namespace declarations: you can't. You are changing the
element name from (V1,FOO) to (V2,FOO). To change an element name, you
can't use <xsl:copy>, you have to use

<xsl:element name="local-name()" namespace="V2">

Generally it's advisable for the default namespace in the stylesheet to
be the same as the default namespace you want in the result document. It
doesn't make sense to use the default namespace from the source
document, because the source document is accessed using path
expressions, and to access a source element in a non-null namespace
within a path expression, you *have* to use a prefix that is bound to
that namespace.

If this isn't your problem, please give us more details of the
transformation you want to perform.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Shea, Michael
> Sent: 05 December 2002 02:31
> To: 'XSL-List@xxxxxxxxxxxxxxxxxxxxxx'
> Subject: [xsl] Default Namespace version problem
> 
> 
> Hey Everybody.
> 
> I'm having troubles with transforming one version of an XML 
> document into a different version.  I have in the first XML 
> file, a default namespace consisting of: 
> xmlns="http://www.blah.com/test/v1".  When I transform this 
> (using Xalan v2.4.D1) I want to change the default namespace 
> to: xmlns="http://www.blah.com/test/v2" in the generated XML 
> file (to reflect the new version of the previous xml file).  
> However, in my xslt stylesheet, I need to have a xmlns tag 
> which specifies: xmlns="http://www.blah.com/test/v1".  The 
> reason that this is the case is if I set the default 
> namespace to v2 then the stlyesheet won't transform the XML 
> documents correctly (the output consists of just the text 
> within the elements, and nothing else). 
> 
> Changing the namespace so that it doesn't use the version in 
> the namespace is not an option as what we are doing is 
> upgrading an already existing XML file into another version.
> 
> Can anyone suggest a way for me to change the namespace from 
> one to another in the output XML file?
> 
> Thanks.
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords