Re: [xsl] Can XSLT Remove <!DOCTYPE...

Subject: Re: [xsl] Can XSLT Remove <!DOCTYPE...
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 13 Apr 2001 10:17:11 +0100
Hi Paul,

Mike Brown wrote:
> paulhoward.co.uk wrote:
>> Ive scoured the archives and Dave's FAQ but I cant find anyway XSLT
>> can be used to remove <!DOCTYPE.... > tags from input files.
>
> XSLT should never see these, since they are not part of the XPath
> data model. They are not intended for the application to see,
> anyway; they are for the XML parser's benefit. XSLT operates on
> parsed XML documents, not the raw input. For the same reason,
> character and entity references are not accessible from within
> XPath/XSLT.

And just to spell out the implication of this... it means that if you
copy an XML document using XSLT, then the copy of that document will
not include the DOCTYPE declaration.  So in effect, you can use XSLT
to 'remove' the DOCTYPE declaration from a document with just one
template:

<xsl:template match="/">
   <xsl:copy-of select="." />
</xsl:template>

There may be other differences between the two documents because the
DTD is missing - the generated document may have extra attributes
because of default attributes within the DTD, and it will not have any
entities aside from the built-in ones.  But logically it will be the
same document.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



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


Current Thread