Subject: Re: [xsl] 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 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] cannot transform to <html, Phillip Rhodes | Thread | RE: [xsl] cannot transform to <html, Paul Brown |
[xsl] XSLT, frames and javascript, Stevenson Ngila | Date | Re: [xsl] Query re XMLSpy XPath eng, David Carlisle |
Month |