[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

xslt & doctype problem

Subject: xslt & doctype problem
From: Glyph <glyph@xxxxxxxxxxx>
Date: Mon, 17 Oct 2005 11:16:36 +1000
xslt include doctype
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 &#160;</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 &nbsp;</p>
</body>
</html>
------------------------------------------

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.