Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: XML::LibXSLT generates invalid XHTML

by arturo (Vicar)
on Jul 19, 2005 at 00:35 UTC ( #475938=note: print w/replies, xml ) Need Help??

in reply to XML::LibXSLT generates invalid XHTML

Well, the same happens using the default jEdit XSLT Plugin, which (surprise surprise) doesn't use LibXML::XSLT. So it's likely not the processor; so I decided to take a gander at the specs, and I found a nasty little surprise:

The default for the method attribute is chosen as follows. If

  • the root node of the result tree has an element child,

  • the expanded-name of the first element child of the root node (i.e. the document element) of the result tree has local part html (in any combination of upper and lower case) and a null namespace URI, and

  • any text nodes preceding the first element child of the root node of the result tree contain only whitespace characters,

then the default output method is html; otherwise, the default output method is xml.

I guess they wanted to have a 'sensible' default and this made sense to a sufficient number of people voting on the spec; I don't agree, it seems like an unnecessary bit of processing and it can be surprising.

Anyhow, since you're wantin' to output XHTML, you should set the default namespace on your stylesheet element to anyways. What would also "work", from the point of view of closing the meta tag, would be to explicitly declare an xsl:output element with a method attribute of xml. I suggest you do both, because you have to in order to generate valid XHTML.

update Actually, what the spec implies is that you only have to add the default namespace in order to get XHTML output. I like adding the xsl:output element anyways, because I usually like to output doctype declarations and set the output encoding explicitly.

If not P, what? Q maybe?
"Sidney Morgenbesser"

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://475938]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2023-01-29 21:31 GMT
Find Nodes?
    Voting Booth?

    No recent polls found