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

Re: What is wrong here?

Subject: Re: What is wrong here?
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 27 Feb 2002 14:04:19 +0000
xmlns html xslt default namespace
Hi Slava,

You've fallen into the namespace trap. In your source document, you've
declared a default namespace:

> <html xmlns="http://www.w3.org/1999/xhtml"
>       xmlns:xlink="http://www.w3.org/1999/xlink">
> <head xmlns="http://www.w3.org/1999/xhtml">
>   <title>Purveyors</title>
> </head>
> <body xmlns="http://www.w3.org/1999/xhtml">
>   <div><p>Body</p></div>
> </body>
> </html>

All the elements in this document are in the XHTML namespace.

In your XSLT, when you match or select an element, you must specify
its namespace by giving it a prefix. So to match an element in the
XHTML namespace, you must declare the prefix in your stylesheet, and
use that prefix to qualify the names you use.

So your stylesheet needs to look like:

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

...
<xsl:template match="html:html">
  <html>
    <xsl:apply-templates select="html:head"/>
    <xsl:apply-templates select="html:body"/>
  </html>
</xsl:template>
...
</xsl:stylesheet>

Note that unless you declare the XHTML namespace as the default
namespace in the stylesheet, all the literal result elements (such as
<html>...</html> in the above) will be in *no* namespace, and not in
the XHTML namespace.

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.