Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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 http://www.w3.org/199/xhtml 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"


Comment on Re: XML::LibXSLT generates invalid XHTML
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (17)
As of 2014-07-11 20:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (235 votes), past polls