By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,229 Members | 1,371 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,229 IT Pros & Developers. It's quick & easy.

XSLT outputting XHTML 4.01 Strict from XHTML 1.0 Strict source

P: n/a
I'm looking for an XSLT that I can use to transform XHTML 1.0 Strict into
HTML 4.01.

Does anyone know of a nice prewritten one?

--
David Dorward <http://dorward.me.uk/>
Jul 20 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
In article <bv*******************@news.demon.co.uk>,
David Dorward <do*****@yahoo.com> writes:
I'm looking for an XSLT that I can use to transform XHTML 1.0 Strict into
HTML 4.01.


The identity XSLT with output method HTML will do exactly that.

The reverse also works if you use an HTML-capable parser.

--
Nick Kew
Jul 20 '05 #2

P: n/a


Nick Kew wrote:
I'm looking for an XSLT that I can use to transform XHTML 1.0 Strict into
HTML 4.01.

The identity XSLT with output method HTML will do exactly that.


Does that really suffice to use an identity transformation with output
method html? I don't think so, if you use the identity transformation
the result elements will be in the XHTML namespace and that means even
with output method html the elements will be serialized according to XML
rules and not HTML rules as the XSLT 1.0 specification states:
an element whose expanded-name has a non-null namespace URI should be
output as XML
Output method html would also not help to get rid of attributes like
xml:lang.
Thus I think instead of simply copying nodes with the identity
transformation you will have to write a stylesheet that throws out the
namespaces, a template for element nodes could look as follows:

<xsl:template match="*[namespace-uri() = 'http://www.w3.org/1999/xhtml']">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@*" />
<xsl:apply-templates select="node()" />
</xsl:element>
</xsl:template>
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3

P: n/a
Martin Honnen <ma*******@yahoo.de> writes:
Output method html would also not help to get rid of attributes like
xml:lang.


I think the "xml:lang" attribute is the only one in XHTML 1.0 that
causes complications. (In XHTML 1.1, there is also the "version"
attribute of the "html" element.) If the XHTML uses "xml:lang"
attributes, a template is needed to transform these to "lang".

<!-- XHMTL xml:lang attribute -->
<xsl:template match="@xml:lang">
<xsl:attribute name="lang">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>

If the XHTML uses both "xml:lang" and "lang" in parallel, a template
is needed to suppress "xml:lang":

<!-- XHMTL xml:lang attribute -->
<xsl:template match="@xml:lang"/>

--
Dean Tiegs, NE¼-20-52-25-W4
“Confortare et esto robustus”
http://telusplanet.net/public/dctiegs/
Jul 20 '05 #4

P: n/a
Dean Tiegs:
(In XHTML 1.1, there is also the "version" attribute of the "html" element.)


Sorry? Never heard of that one.

--
Bertilo Wennergren <be******@gmx.net> <http://www.bertilow.com>
Jul 20 '05 #5

P: n/a
In article <bv*******************@news.demon.co.uk>,
David Dorward <do*****@yahoo.com> wrote:
I'm looking for an XSLT that I can use to transform XHTML 1.0 Strict into
HTML 4.01.


Are you looking for an XSLT solution specifically or just a method for
converting XHTML 1.0 Strict to HTML 4.01 Strict? If the latter, you
could just use an HTML serializer as the ContentHandler of a SAX parser.

--
Henri Sivonen
hs******@iki.fi
http://iki.fi/hsivonen/
Mozilla Web Author FAQ: http://mozilla.org/docs/web-developer/faq.html
Jul 20 '05 #6

P: n/a
Bertilo Wennergren <be******@gmx.net> writes:
Dean Tiegs:
(In XHTML 1.1, there is also the "version" attribute of the "html"
element.)
Sorry? Never heard of that one.


It's complete undocumented (as far as I know), but it's there. The
DTD sets the version attribute of the html element to
"-//W3C//DTD XHTML 1.1//EN" through the use of a #FIXED attribute
declaration.

In xhtml11-flat.dtd, the following lines are involved:

Line 34: <!ENTITY % XHTML.version "-//W3C//DTD XHTML 1.1//EN" >

Lines 4495 to 4506:

<!ENTITY % XHTML.version.attrib
"version %FPI.datatype; #FIXED '%XHTML.version;'"
<!-- see the Qualified Names module for information
on how to extend XHTML using XML namespaces
-->
<!ATTLIST %html.qname;
%XHTML.xmlns.attrib;
%XHTML.version.attrib;
%I18n.attrib;


--
Dean Tiegs, NE¼-20-52-25-W4
“Confortare et esto robustus”
http://telusplanet.net/public/dctiegs/
Jul 20 '05 #7

P: n/a
Nick Kew wrote:
In article <bv*******************@news.demon.co.uk>,
David Dorward <do*****@yahoo.com> writes:
I'm looking for an XSLT that I can use to transform XHTML 1.0 Strict into
HTML 4.01.


The identity XSLT with output method HTML will do exactly that.


Oh drat, its got that in it already.

Must be a limitation of the parser (PHP's XMLDOM)

--
David Dorward <http://dorward.me.uk/>
Jul 20 '05 #8

P: n/a
In article <bv*******************@news.demon.co.uk>,
David Dorward <do*****@yahoo.com> writes:
I'm looking for an XSLT that I can use to transform XHTML 1.0 Strict into
HTML 4.01.


The identity XSLT with output method HTML will do exactly that.


Oh drat, its got that in it already.

Must be a limitation of the parser (PHP's XMLDOM)


If the context is PHP, then presumably the context is also Apache?
You could transform to HTML4 in an output filter, using SAX for a tiny
fraction of the overhead of XSLT.

Take your pick of my relevant modules (at http://apache.webthing.com/ )
Any of mod_proxy_html, mod_accessibility, mod_xml, or mod_xmlns could
do it as a side-effect of their main purpose!

--
Nick Kew
Jul 20 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.