[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Reprocessing XHTML with XSLT
You'll probably find that harmless-looking XHTML DTD is declaring a default namespace for you - a practice which should be punishable by flogging. Michael Kay Software AG home: Michael.H.Kay@xxxxxxxxxxxx work: Michael.Kay@xxxxxxxxxxxxxx > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of > Peter Flynn > Sent: 31 October 2002 22:34 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Reprocessing XHTML with XSLT > > > 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 > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|