tags:

views:

839

answers:

2

Hi All, using xslt I am trying to get xhtml o/p .I have used xmlns="http://www.w3.org/1999/xhtml" in

<xsl:stylesheet>

to get xhtml o/p.Every thing is fine but in the first div I am getting the same namespace. i.e.

 <div  xmlns="http://www.w3.org/1999/xhtml"&gt;

Now how to remove xmlns="http://www.w3.org/1999/xhtml"

+1  A: 

Why would you want to remove the namespace? It's part of the XHTML specification, and you say you want XHTML output. So - where's the problem?

Apparently you start your output with <div>, otherwise you would have the namespace declaration on the <html> element.

Tomalak
thats true it will come in <html> but is there any way to remove the namespace.
Wondering
Again: Why? It *belongs* to XHTML, it *has to* be there.
Tomalak
+2  A: 

As others have pointed out, you may not want to do this. If you want the output to be XHTML, you need to keep the XHTML namespace declaration.

That being said, if you really want to do it:

<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;

  <!-- attributes, commments, processing instructions, text: copy as is -->
  <xsl:template match="@*|comment()|processing-instruction()|text()">
    <xsl:copy-of select="."/>
  </xsl:template>

  <!-- elements: create a new element with the same name, but no namespace -->
  <xsl:template match="*">
    <xsl:element name="{local-name()}">
      <xsl:apply-templates select="@*|node()"/>
    </xsl:element>
  </xsl:template>

</xsl:stylesheet>
Jukka Matilainen