473,508 Members | 2,088 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSLT outputting XHTML 4.01 Strict from XHTML 1.0 Strict source

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
8 2567
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


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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2681
by: Sergio del Amo | last post by:
Hi, I use the xslt functions provided by php. I am running in my computer the package xampp(www.apachefriends.org) which includes php/apache/mysql .. In this package the php includes the sablotron...
2
3163
by: Jesper Moth | last post by:
The MSXML4 xslt-parser would output any source <div/> like this: <div></div> I never figured out how to disable this behaviour. But since it makes the source document look cleaner, and since...
20
6732
by: Bernd Fuhrmann | last post by:
Hi! I have some trouble with some simple stupid XSLT-stuff. My stylesheet: ------------- <?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet version="1.0"...
3
1894
by: Francis Hwang | last post by:
Hi, Maybe this is a newbie question, but: Is there a way to output an element's contents -- including contained nodes and free-form text -- without the containing tags? I can imagine that...
13
3624
by: Tjerk Wolterink | last post by:
Hello i've an xsl stylesheet that must support xhtml entities, my solution: ---- <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE xsl:stylesheet > <xsl:stylesheet version="1.0"...
2
1111
by: jopaki | last post by:
Hello all, I am relatively new to XSLT. I am attempting to transform XML and everyting is cool until I introduce these top lines in the source XML (really XHTML): --------- <?xml...
3
1748
by: Andrew Jocelyn | last post by:
Hi Is there a way of outputting some xml tags during an XSLT transform? For example when I use the 'xsl:value-of select="xhtml"' statement I'd like to output the children of 'xhtml' after the...
21
4570
by: =?iso-8859-2?Q?K=F8i=B9tof_=AEelechovski?= | last post by:
It is common knowledge that XHTML is better HTML and you can serve XHTML content as HTML. However, the second statement is incorrect, for various reasons; it is enough to say that the HTML...
0
7124
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7385
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7046
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7498
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3195
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1558
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.