Subject: Re: [xsl] xsl:element will not create an output element, in any context From: "N David Brown" <orieldave@xxxxxxxxxxxxxx> Date: Thu, 31 May 2007 17:46:54 +0100 |
Awesome info! I'm still not home, but will take what you've said into account when testing.
See my comments, I made a few mistakes that may put you on the wrong foot:
> > <?xml version="1.0" encoding="UTF-8"?> > <?xml-stylesheet type="text/xsl" href="embedded.xslt"?> > <xsl:stylesheet > xmlns="http://www.w3.org/1999/xhtml" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0" > > > <xsl:output method="html"
Using XSLT 1.0, this should be method="xml". Using XSLT 2.0, this should be method="xhtml". Some XSLT 1.0 are reported to support method="xhtml" as an extension.
When you set this to "html", the output may not be well-formed XML (br /> becomes <br> etc), and as such may become illegal XHTML.
> doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" > doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/> > > <xsl:template match="/"> > <html xml:lang="en" lang="en">
I was referring to "conformant xhtml". to be xhtml 1.0 strict, it is not necessary to have the xml:lang or lang attributes.
The minimum you require in the output is the <html> root element, a head+title and a body plus at least one content element.
> <head><title>hello world</title></head> > <body> > <h1>Hello world!</h1> > </body> > </html> > </xsl:template> > </xsl:stylesheet> >
Sorry for any possible confusion.
In addition, I like to emphasize problems that may rise when trying to output XHTML with an XSLT 1.0 procesosor on certain user agents when using the XML output method for generating XHTML.
1. Empty elements whose content model is not empty. I.e.: <p /> should be output as <p></p> and <script /> should be output as <script></script>
2. Elements that have an empty content model (i.e., never may have any content), the output should be the minimized form, i.e.: <br></br> becomes <br />, <img></img> becomes <img />.
3. Before the trailing slash of a minimized element must come a space. I.e., <br/> should become <br />.
4. ' should not be output, instead, the numeric entity should be used.
5.... etc (some more prb are known)
XSLT 2.0 deals with all these problems when you set the xhtml outpout method. In XSLT 1.0, using the XML output method, this is not enforced. Using the HTML output method, you get non-well-formed XHTML. Your best option is to use a processor that can handle the XHTML output method.
Cheers, -- Abel Braaksma
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xsl:element will not crea, Abel Braaksma (onlin | Thread | Re: [xsl] xsl:element will not crea, N David Brown |
Re: [xsl] Fwd:[xsl] REMOVE FROM MAI, Mulberry Technologie | Date | [xsl] NFA to DFA conversion using X, Mukul Gandhi |
Month |