[xsl] RE: how XSL processor treat doctype declaration in source

Subject: [xsl] RE: how XSL processor treat doctype declaration in source
From: Scott.Hayman@xxxxxxxxxxx
Date: Wed, 11 Apr 2001 14:47:20 -0400
> If this is so, then why is it that I get weird results if I
   > include the doctype declaration in my source file?

   The XSLT processor won't even *see* the doctype decl, that's handled
   entirely in the XML parser. I think you need to give us a concrete
   example
   of what you're doing: tell us what products you are using and how you
   are
   invoking them. (Preferably, see if several products give you the same
   effect)

I've got a concrete example of this behavior and at a complete loss as to
why the results differ.  I've tried running the transformation with both
saxon (instant-saxon 6.0.2) and Xalan (v1 and v2), all with the same
effect.

The XML I am using is:

   <?xml version="1.0" ?>

   <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20001102//EN"
      "http://www.w3.org/TR/2000/CR-SVG-20001102/DTD/svg-20001102.dtd";>

   <svg width="120" height="130">

       <polygon style="fill:limegreen" points="92,110 112,80 112,110" />

   </svg>

The XSL is:

   <?xml version="1.0" ?>
   <xsl:stylesheet
           version="1.0"
           xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

      <xsl:template match="svg">
           <xsl:comment> svg element </xsl:comment>
           <xsl:copy>
                <xsl:apply-templates/>
           </xsl:copy>
       </xsl:template>

      <xsl:template match="polygon">
           <xsl:comment>polygon</xsl:comment>
           <xsl:copy>
                <xsl:apply-templates/>
           </xsl:copy>
       </xsl:template>

   </xsl:stylesheet>

The output I get with the DOCTYPE declaration is:

   <?xml version="1.0" encoding="UTF-8"?>

The output I get without the DOCTYPE declaration is:

   <?xml version="1.0" encoding="UTF-8"?>
   <!-- svg element --><svg>

       <!--polygon--><polygon/>

   </svg>

What in the DTD causes the result of the transformation to differ?  Is
there anyway in the XSL to get around this?

Any help would be much appreciated.

Thanks,
Scott
--
Scott Hayman
Software Designer
Plazmic Inc.
425 Bloor Street East, Suite 300
Toronto, Ontario, Canada M4W 3R5
416.863.9755 ext 222 (direct)
416.863.9785 (fax)
Scott.Hayman@xxxxxxxxxxx
http://www.plazmic.com



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread