Re: [xsl] xsl:element will not create an output element, in any context

Subject: Re: [xsl] xsl:element will not create an output element, in any context
From: "Abel Braaksma (online)" <abel.online@xxxxxxxxx>
Date: Thu, 31 May 2007 15:38:56 +0200 (CEST)
> Ok, thanks David and Abel for your latest emails; I'll have to wait
> a
> few hours until I'm back home from work to test things in the
> browser
> now.

You can just put the example in the filesystem and open it in Firefox.


>
> One last question for David, before I test things when back at home.
> What you've written below produces 'ul' and 'li' elements in no
> namespace, according to what you said earlier. I'm assuming this
> means
> they will NOT be processed as XHTML elements, and hence will not
> produce the result I want (which is XHTML ul and li elements)?

For a browser it is more important that the DOCTYPE is correct. You
can set it in the <xsl:output /> instruction. However, it will not
effect the result when you use a doctype in an inlined stylesheet
(another difference from server side and client side rendering using
<?xml-stylesheet ?>)

In addition of being conformant XHTML, the elements may not have a
prefix and must be in the XHTML namespace. The previous example
changed such a way that it produces conformant XHTML when run from a
commandline processor, may look like this (place it in your
filesystem and point your firefox browser to it):

<?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"
      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">
            <head><title>hello world</title></head>
            <body>
                <h1>Hello world!</h1>
            </body>
        </html>
    </xsl:template>
</xsl:stylesheet>


Cheers,
-- Abel Braaksma

Current Thread