This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: What is wrong here?
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: "Slava Sedov" <slava dot sedov at imge dot ru>
- Cc: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 27 Feb 2002 14:04:19 +0000
- Subject: Re: [xsl] What is wrong here?
- Organization: Jeni Tennison Consulting Ltd
- References: <008101c1bf80$70a3d9f0$e5f2a3c3@gustaf><000d01c1bf88$13db6f50$050aa8c0@team.imge.ru>
- Reply-to: xsl-list at lists dot mulberrytech dot com
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