[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: cannot transform to <html xmlns="http://www.w3.org

Subject: Re: cannot transform to <html xmlns="http://www.w3.org/1999/xhtml">
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Mon, 22 Jul 2002 09:48:39 +0100
default namespace prefix html xhtml
Hi Phillip,

> My problem is that the xhtml to fo conversion does not work unless
> the html element appears as:
>
> <html xmlns="http://www.w3.org/1999/xhtml">
> </html>

In other words, the XHTML to XSL-FO conversion requires that the html
element (and other elements, I imagine) are in the XHTML namespace.
They need to be in the XHTML namespace because that's what the
transformation uses to identify elements that it knows how to convert.

> Unfortunately, my xhtml file's html element(after transformation)
> is:
>
> <html xmlns:html="http://www.w3.org/1999/xhtml">
> </html>

In other words, you're creating an html element in *no namespace*
(there's no default namespace declaration, so elements without a
prefix are in no namespace). You happen to have the XHTML namespace
associated with the prefix 'html' but I guess there's nothing in your
stylesheet that uses the prefix 'html' so the namespace declaration
doesn't do much.

To create an html element with no prefix and in the XHTML namespace,
you need to declare the XHTML namespace as the default namespace
within your stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns="http://www.w3.org/1999/xhtml">

<xsl:template match="/">
  <html>
  </html>
</xsl:template>

</xsl:stylesheet>

Note that placing the default namespace declaration on the
xsl:stylesheet element means that its scope is the entire stylesheet
-- any literal result element that doesn't have a prefix will be
placed in the XHTML namespace. That's what you want to happen.

Paul Brown's suggestion of:

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

will place the html element in the XHTML namespace, and it will place
any literal result element actually inside that html element *in the
stylesheet* in the correct namespace. However, if you had something
like:

<xsl:template match="/">
  <html xmlns="http://www.w3.org/1999/xhtml">
    <xsl:apply-templates />
  </html>
</xsl:template>

<xsl:template match="/*">
  <head>
  </head>
  <body>
  </body>
</xsl:template>

then the head and body elements would again be in no namespace, since
there is no default namespace declaration that covers them.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.