Subject: Re: [xsl] What is wrong here? From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Wed, 27 Feb 2002 14:04:19 +0000 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] What is wrong here?, Slava Sedov | Thread | Re: [xsl] <br/> in FO?, Nitin . Jain |
Re: [xsl] getting the node position, Jeni Tennison | Date | RE: [xsl] getting the node position, Gurvinder Singh |
Month |