Re: [xsl] Reprocessing XHTML with XSLT

Subject: Re: [xsl] Reprocessing XHTML with XSLT
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 31 Oct 2002 17:47:08 -0500
Hi Peter,

I don't think you've missed anything in the specs or in XSLT. As for the neural half-life problem, I can't say, but....

I'd double-check to make sure that
(a) no higher-level wrappers are getting matched by a template that says to do nothing (if you're getting the contents dumped, however, this won't be the case), and
(b) no <xsl:value-of select="."/> instructions have slipped in in place of an <xsl:apply-templates/>

But your code as presented really ought to work (and it does on my system). When I run your samples as given, I get the output:

<?xml version="1.0" encoding="utf-8"?>
<modules><module>a heading</module></modules>


At 05:33 PM 10/31/2002, you wrote:
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.

Minimal example:

---------- test.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    <title>some title</title>
        <td>stuff to ignore</td>
        <td>more stuff</td>
    <h2>a heading</h2>
    <p>just text</p>

---------- extract.xsl

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="";

<xsl:output method="xml"/>

<xsl:strip-space elements="*"/>

  <xsl:template match="/">

  <xsl:template match="html">

<xsl:template match="head | table | p"/>

  <xsl:template match="body">

  <xsl:template match="h2">


---------- 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:

Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.      
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

XSL-List info and archive:

Current Thread