Subject: Re: [xsl] Reprocessing XHTML with XSLT From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Thu, 31 Oct 2002 17:47:08 -0500 |
<?xml version="1.0" encoding="utf-8"?> <modules><module>a heading</module></modules>
Cheers, Wendell
I've either lost those last few remaining neurons, or I've missed something rather important in the documentation (it's the first time I've needed to do an XML-to-XML transformation in anger, too :-)
I had a moderately well-formed HTML file from a user which I ran through Tidy -asxml to turn it into WF XHTML. I mended some errors* and it's now valid. I then started writing some XSLT (below) to turn it into the required XML markup.
But running it through xt or Cocoon only fires the document root template and nothing else, so I get output with the data content enclosed in the specified root element tags (<modules>...</modules>) and the rest is dogfood -- as if I had not specified any other templates. I've tried with both the literal result elements and with <xsl:element> but the same occurs.
Why is it failing to match the remaining templates? There doesn't seem to be anything in Dave's FAQ or any of the books I've got, which only cover XHTML *output*, so I'm making the conclusion that I've missed something significant in the spec.
///Peter -- Minimal example:
---------- test.xhtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/dtds/xhtml1-transitional.dtd"> <html> <head> <title>some title</title> </head> <body> <table> <tr> <td>stuff to ignore</td> <td>more stuff</td> </tr> </table> <h2>a heading</h2> <p>just text</p> </body> </html>
---------- extract.xsl
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/"> <modules> <xsl:apply-templates/> </modules> </xsl:template>
<xsl:template match="html"> <xsl:apply-templates/> </xsl:template>
<xsl:template match="head | table | p"/>
<xsl:template match="body"> <xsl:apply-templates/> </xsl:template>
<xsl:template match="h2"> <module> <xsl:apply-templates/> </module> </xsl:template>
</xsl:stylesheet>
---------- output
<?xml version="1.0" encoding="utf-8"?> <modules>some titlestuff to ignoremore stuffa headingjust text</modules>
---------- * It appears that Tidy fails to convert NAME attributes which are comprised of digits only to a suitable form beginning with a letter when it outputs them as ID values, in order to conform with being XML Names.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Reprocessing XHTML with XSLT, Peter Flynn | Thread | Re: [xsl] Reprocessing XHTML with X, Peter Flynn |
[xsl] Reprocessing XHTML with XSLT, Peter Flynn | Date | RE: [xsl] Using substring call with, Michael Kay |
Month |