Re: XSLT and Text Processing Languages

Subject: Re: XSLT and Text Processing Languages
From: Mike Brown <mike@xxxxxxxx>
Date: Thu, 7 Sep 2000 18:11:00 -0600 (MDT)
Matthew Bentley wrote:
> I don't know what you're talking about, but its certainly nothing to do
> with the solution I was suggesting.

It was proposed by someone else that you use what you called the CDATA
hack -- making a text node child of the root node, with
disable-output-escaping="yes", to fake a document type declaration. The
result tree would graph out rougly like this:

root
 |___text '<!DOCTYPE ...>' [+ output escaping disabled]
 |___element 'foo'
        |___ ...

Initially my concern was that this result tree could only be serialized
via the XML output method when the text node was something allowed before
the document element (foo). That is, it would only work if the disablement
of output escaping was successful (which it isn't guaranteed to be) and if
the text created were whitespace, a comment, or a <!DOCTYPE>.

Upon closer reading of the XML output method spec at
http://www.w3.org/TR/xslt#section-XML-Output-Method, I see that it's not
intended to output well-formed *document entity* unless the result tree
contains no text node children of the root node at all.

If there is a text node child of the root node, as there would be if you
were faking a <!DOCTYPE> in this manner, then the requirement of the
output being a well-formed document is scaled back to being just a
well-formed external general parsed entity.

"When the entity is referenced within a trivial XML document wrapper like
this

<!DOCTYPE doc [
<!ENTITY e SYSTEM "entity-URI">
]>
<doc>&e;</doc>

where entity-URI is a URI for the entity, then the wrapper document as a
whole should be a well-formed XML document conforming to the XML
Namespaces Recommendation."

When I had read that sentence earlier today, I was thinking "if the entity
contains a <!DOCTYPE>, it can't go into the <doc>...</doc>, so it must be
wrong to put a <!DOCTYPE> into the output" ...

> Certainly, you are correct that you can't put a doctype inside an element.
> But in case you've forgotten, the root node is not an element.

I was mistaken -- not for the reason you suggest, but because I forgot
that the entity is *external*. This means it may have a text declaration
like <?xml version="1.0" encoding="foo"?> but no standalone declaration,
and it may have a <!DOCTYPE> as well. These things will be not be
considered part of the general entity's replacement text.

I withdraw the warning. Sorry for the confusion.

   - Mike
____________________________________________________________________
Mike J. Brown, software engineer at         My XML/XSL resources:
webb.net in Denver, Colorado, USA           http://www.skew.org/xml/


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


Current Thread