xsl xmlns question

Here should go questions about transforming XML with XSLT and FOP.
thomasa
Posts: 3
Joined: Thu Nov 25, 2010 6:21 pm

xsl xmlns question

Post by thomasa »

Hi!

I'm using oxygen to convert xml to xhtml. In the process I get an xmlns attribute in some of the resulting xhtml tags -- like this:

<xmltag>Heading</xmltag>

becomes

<h1 xmlns:"">Heading<h1>

xsl says: <xsl:template match="xmltag"><h1><xsl:value-of select="."/></h1></xsl:template>

How to get rid of the xmlns:""?

Thomas
thomasa
Posts: 3
Joined: Thu Nov 25, 2010 6:21 pm

Re: xsl xmlns question

Post by thomasa »

Sorry, that would be <h1 xmlns:"">Heading</h1> of course... /Thomas
adrian
Posts: 2855
Joined: Tue May 17, 2005 4:01 pm

Re: xsl xmlns question

Post by adrian »

Hello,

Are you sure it's not really xmlns="" ? xmlns:"" seems unlikely, it's not even XML well formed.

The problem is namespace related. You probably have an element in the stylehseet that specifies the XHTML namespace.
e.g.
<html xmlns="http://www.w3.org/1999/xhtml">

But then subsequent elements don't have the namespace specified.
If all the elements from the output are from the same namespace as is the case for XHTML you can either specify the namespace for each of them(which is a burden) or add add the default namespace declaration:
xmlns="http://www.w3.org/1999/xhtml" to the stylesheet root: <xsl: stylesheet.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
thomasa
Posts: 3
Joined: Thu Nov 25, 2010 6:21 pm

Re: xsl xmlns question

Post by thomasa »

Hmm... did some typing errors in my post. You're right, it is xmlns="".

Removed xmlns="http://www.w3.org/1999/xhtml" in the <html> tag and put it in the <xsl:stylesheet instead.

Now everything is fine! Thanks a lot for helping!

Thomas
Post Reply