[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: XHTML to HTML 4

Subject: Re: XHTML to HTML 4
From: Eric van der Vlist <vdv@xxxxxxxxxxxx>
Date: Thu, 06 Apr 2000 18:35:28 +0200
xslt transform xhtml to html
The nasty part of the transformation is the &lt;p&gt; which is adding
nodes in the middle of a text...

Otherwise, it's a matter of transforming the namespaces and letting the
html output method do the trick...

There maybe simpler solutions, but something like :

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:html='http://www.w3.org/1999/xhtml'
  exclude-result-prefixes = "html">
<xsl:output method="html"
	doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"/>

<xsl:template match="*">
	<xsl:element name="{local-name(.)}">
		<xsl:apply-templates select="@*|node()"/>
	</xsl:element>
</xsl:template>

<xsl:template match="@*">
	<xsl:attribute name="{local-name(.)}">
		<xsl:value-of select="."/>
	</xsl:attribute>
</xsl:template>

</xsl:stylesheet>

would be sufficient (and you can add templates if you want to have a
specific behavior for a specific HTML tag).

To include your <p>, you'd need to add a template like

<xsl:template match="text()" name="text">
        <xsl:param name="text" select="."/>
        <xsl:choose>
        <xsl:when test='contains($text, "&lt;p&gt;")'>
	   <xsl:value-of select='substring-before($text, "&lt;p&gt;")'/>
           <p/>
           <xsl:call-template name="text">
             <xsl:with-param name="text" select='substring-after($text,
"&lt;p&gt;")'/>
           </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
           <xsl:value-of select="$text"/>
        </xsl:otherwise>
        </xsl:choose>
</xsl:template>

Hope this helps.

Eric

-- 
------------------------------------------------------------------------
Eric van der Vlist       Dyomedea                    http://dyomedea.com
creator                  http://xmlfr.org            http://ducotede.com
editor                   http://xmlhack.com              http://dmoz.org
------------------------------------------------------------------------


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.