[xsl] Adding namespace to an XML through XSL

Subject: [xsl] Adding namespace to an XML through XSL
From: Kanthi <kan_manikoth@xxxxxxxxx>
Date: Tue, 30 Dec 2003 08:05:46 -0800 (PST)
Hi there - 

I am having problems adding a namespace using an xsl
to an xml with no namespaces.  

My sample xml looks like this
<MainElement>
  <Element1>
   <Element2>
     <Element3> 
      :
      :
     </Element3>
   </Element2>
  </Element1>
</MainElement>

And I want to add a namespace to the <MainElement
xmlns="Something"> without any prefix.

I am doing the following in my xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns="Something">
<xsl:output method="xml" version="1.0"
encoding="utf-8" indent="yes"
omit-xml-declaration="yes"/>

<xsl:template match="MainElement">
<MainElement xmlns="Something">
  <xsl:copy-of select="."/>
</MainElement>	
</xsl:template>

</xsl:stylesheet>

But the problem is that <Element1> looks like this
<Element1 xmlns="">

Any ideas on how to get round this?  I am not exactly
sure how to use "xsl:namespace-alias" for this or
whether that will help?

 
Thanks
Kanthi

__________________________________
Do you Yahoo!?
Find out what made the Top Yahoo! Searches of 2003
http://search.yahoo.com/top2003

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


Current Thread