Toseef Zafar
Toseef Zafar

Reputation: 1787

xslt adds "ns0" with the namespace attribute with root element, how to avoid this?

I am using namespace attibute of xsl:element to put a namespace in the result XML. It puts the namespace in there, but like this:

xmlns:ns0="http://...." 

and puts <root> as <ns0:root>. I want to put the namespace without "ns0".

Upvotes: 2

Views: 1574

Answers (1)

Dimitre Novatchev
Dimitre Novatchev

Reputation: 243599

<xsl:element name="myroot" namespace="xmlns.mynamespace.com/import">;
  <xsl:attribute name="version">
    <xsl:text>2.0</xsl:text>
  </xsl:attribute>
  <xsl:apply-templates />
</xsl:element>

Simply re-write this as:

<myroot xmlns="xmlns.mynamespace.com/import" version="2.0">
  <xsl:apply-templates />
</myroot>

Upvotes: 2

Related Questions