[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] xslt & doctype problem
Subject: RE: [xsl] xslt & doctype problem From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Mon, 17 Oct 2005 08:52:26 +0100 |
The XHTML DTD declares a default namespace, in the guise of a defaulted attribute value for the <html> element. Not a nice thing to do, because its effect is to put all the unprefixed elements in your source document into a namespace. This means they will not match unprefixed names used as match patterns in your stylesheet. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Glyph [mailto:glyph@xxxxxxxxxxx] > Sent: 17 October 2005 02:17 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] xslt & doctype problem > > I have a problem whereby if I include an xhtml doctype > declaration in my > > html then my xslt templates always match the wildcard. > > Ive constructed a simple demonstration of a problem Im > having, hoping a > sage older hand can tell me where Ive gone wrong. > It includes a simple transform, and two xhtml files which > have two minor > differences: in the second I include the DOCTYPE declaration, and can > thus use the nbsp by name. > > If I process them with xalan 2.7 (I had similar problems with > msxml, and > switched because I hoped xalan might be different) the 'head' > and 'body' > tags in the second file is always matched by the wildcard template. > > java.exe -classpath %CLASSPATH% org.apache.xalan.xslt.Process -IN > dummy.html -XSL dummy-clean.xslt > > java.exe -classpath %CLASSPATH% org.apache.xalan.xslt.Process -IN > dummy2.html -XSL dummy-clean.xslt > > Hoping its something stupid (and thus easy to fix) > -G. > > ----- clean.xslt --------------------------------- > <?xml version="1.0" encoding="ISO-8859-1"?> > > <xsl:transform version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > > <xsl:output > method="html" > version="4.0" > encoding="iso-8859-1" indent="yes" > omit-xml-declaration="yes"/> > > <!-- start at root of document --> > <xsl:template match="/"> > <xsl:message terminate="no"> > Trace: root -<xsl:value-of select="name()" />- > </xsl:message> > <html> > <xsl:apply-templates select="*" /> > </html> > </xsl:template> > > <xsl:template match="html"> > <xsl:message terminate="no"> > Trace: html > </xsl:message> > <xsl:copy> > <xsl:apply-templates select="*" /> > </xsl:copy> > </xsl:template> > > <xsl:template match="head"> > <xsl:message terminate="no"> > Trace: head > </xsl:message> > <xsl:copy> > <xsl:if test="not(title)"> > <title> No Title Given </title> > </xsl:if> > <xsl:apply-templates /> > </xsl:copy> > </xsl:template> > > <xsl:template match="body"> > <xsl:message terminate="no"> > Trace: body > </xsl:message> > <xsl:copy> > <h1> > <!-- potentially empty header --> > <xsl:copy-of select="../head/title" /> > </h1> > <xsl:apply-templates mode="inner" /> > </xsl:copy> > </xsl:template> > > <!-- copy generic nodes --> > <xsl:template match="*"> > <xsl:copy> > <xsl:copy-of select="@*" /> > <xsl:message terminate="no"> > Trace: generic -<xsl:value-of select="name()" />- > </xsl:message> > <xsl:apply-templates /> > </xsl:copy> > </xsl:template> > > <!-- copy generic nodes without trace --> > <xsl:template mode="inner" match="*"> > <xsl:copy> > <xsl:copy-of select="@*" /> > <xsl:apply-templates mode="inner" /> > </xsl:copy> > </xsl:template> > > </xsl:transform> > ------------------------------------------ > > > ----dummy.html-------------------------- > <html> > <head> > <meta name="fish" value="Carp" /> > </head> > <body> > <h1>carp</h1> > <p>Im not going to harp on about carp</p> > <p>Just going to include a simple  </p> > </body> > </html> > ------------------------------------------ > > > ----dummy2.html-------------------------- > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > > <html> > <head> > <meta name="fish" value="Carp" /> > </head> > <body> > <h1>carp</h1> > <p>Im not going to harp on about carp</p> > <p>Just going to include a simple </p> > </body> > </html> > ------------------------------------------
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xslt & doctype problem, David Carlisle | Thread | [xsl] Help getting started with XSL, Karl Stubsjoen |
Re: [xsl] xslt & doctype problem, andrew welch | Date | Re: [xsl] Help getting started with, andrew welch |
Month |