xsl-list
[Top] [All Lists]

Re: [xsl] xml to xhtml namespace problem

2011-01-11 04:48:49
<h1 xmlns="">...</h1>

How can I get rid of that empty namespace ?!

When you have:

<xsl:template match="/*">
  <html xmlns="http://www.w3.org/1999/xhtml";>
  </html>
</xsl:template>

<xsl:template match="foo">
  <h1>   </h1>
</xsl:template>

It's tempting to think the <h1> in the 2nd template gets put in the
xhtml namespace because it gets added beneath the <html> element in
the result tree... however it needs to be put in the the xhtml in the
stylesheet.  You do this either by doing:

<h1 xmlns="http://www.w3.org/1999/xhtml";>

or by moving the default namespace change to a common ancestor of all
the elements, usually the root element:

 <xsl:stylesheet version="2.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
   xmlns="http://www.w3.org/1999/xhtml";>

If that doesn't make sense, try using a prefix - you will see that you
need to need declare the prefix on a common ancestor.

-- 
Andrew Welch
http://andrewjwelch.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>