.
Developer Spot - Web Development Tutorials
 


Web Hosting Directory
Budget Web Hosting Linux Web Hosting Small Business Hosting
Windows Web Hosting Reseller Web Hosting Web Hosting Articles

Tip: Convert from HTML to XML with HTML Tidy

By Benoit Marchal
2003-12-16
Reader Rating: 5 out of 5
Bookmark Print Version
Listing 4. cleanup.xsl

<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:gl="http://ananas.org/2003/tips/gallery"
xmlns:html="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="html">

<xsl:output method="xml" indent="yes" encoding="MacRoman"/>

<xsl:template match="html:html">
<xsl:variable name="date"
select="html:body/html:table/html:tr/html:td[2]
/html:font/html:br[3]
/preceding-sibling::text()[1]"/>
<gl:gallery>
<gl:title>
<xsl:value-of select="html:head/html:title"/>
</gl:title>
<xsl:for-each select="html:body/html:center/html:table
/html:tr/html:td">
<xsl:variable name="title"
select="html:font/html:br[3]
/preceding-sibling::text()[1]"/>
<xsl:variable name="image"
select="html:font/html:br[1]
/preceding-sibling::text()[1]"/>
<xsl:variable name="description"
select="html:font/html:br[2]
/preceding-sibling::text()[1]"/>
<gl:photo>
<gl:title><xsl:value-of
select="normalize-space($title)"/></gl:title>
<gl:date><xsl:value-of
select="normalize-space($date)"/></gl:date>
<gl:image><xsl:value-of
select="normalize-space($image)"/></gl:image>
<gl:description><xsl:value-of
select="normalize-space($description)"/></gl:description>
</gl:photo>
</xsl:for-each>
</gl:gallery>
</xsl:template>

</xsl:stylesheet>




Article Pages:
Preserve Legacy Web Sites With This Handy Utility
Tool Of The Trade
Listing 1. index.html (an excerpt)
Tidying Up
Listing 2. index.xml (an excerpt)
Further Processing
Listing 3. index-transform.xml (an excerpt)
Listing 4. cleanup.xsl
Conclusion

First published by IBM developerWorks


 Rate this article:   Poor          Excellent 


If you found this article interesting, you may want to read these as well:

» Better SOAP Interfaces With Header Elements

» Variable Substitution In XML Documents

» Create JPEGs Automatically With SVG

» Grab Headlines From A Remote RSS File



 
Development Tutorials
ASP
CGI & Perl
CSS
HTML
Java
JavaScript
Linux
PHP
XML




More Resources
Web Hosting Articles
Development Tutorials: CGI & Perl - CSS - HTML - Java - JavaScript - Linux - PHP - XML