xsl-list
[Top] [All Lists]

Re: [xsl] Setting default namespace in document output with <xsl:result-document>

2011-04-25 16:36:04
On 25 April 2011 22:09, Steve Fogel <STEVE(_dot_)FOGEL(_at_)oracle(_dot_)com> 
wrote:

Hi, all.

I'm wondering how to set the default namespace in, say, the <html> tag of an 
output document when creating the document with <xsl:result-document>.

I would like the <html> tag to look like this:

<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">

Right now it looks like this:

<html xml:lang="en" lang="en">

Just write that directly eg:

<xsl:result-document  ...>
  <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">

...or set the default namespace on an ancestor of the <html> literal
result element in the xml-that-is-the-xslt, which is a long way of
saying set the xhtml namespace on your xsl:stylesheet element.



I would also like any <link> or <meta> elements in the <head> section to not 
contain namespace declarations. In other words, I want to avoid what I'm 
getting now, which is:

<meta xmlns="http://www.w3.org/1999/xhtml"; http-equiv="Content-Type" 
content="text/html; charset=utf-8"></meta>
.
<link xmlns="http://www.w3.org/1999/xhtml"; rel="copyright" 
href="../../dcommon/html/cpyr.htm" title="Copyright" type="text/html"></link>
.

That will resolve itself once the ancestor <html> is in the right
namespace, but again its caused by scoping of the namespace in the
xml-that-is-the-xslt... Its intuitive to think that because an element
is added to the result as a descendant of <html> it will take on the
default namespace, but its the location in your stylesheet that
decides what default namespace it has.  A good thing to do until the
penny drops is to use a prefix for the xhtml namespace, then its
pretty clear.


-- 
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>