Valid XML document

Didier PH Martin martind at
Wed Nov 24 18:54:17 GMT 1999

Hi Steve

I noticed what you are saying when I tried the small doc in a XML parser.
Sorry, I responded too fast without doing double checking on the doc.
Anyway, thanks for bringing rigor to the message.

Nevertheless the problem with validating a document composed of fragments is
still open and DTDs are not the solution like we both demonstrated ;-).

Also, we can take here the opportunity to mention that section 2.7 of the
XSLT recommendation can potentially lead to misinterpretation by including a
DTD in the example. By doing so, as Steve demonstrated so well, we would
have to include any element and attribute definition about the document.
This would include of course all our elements + the XSLT elements used. It
would be better to use as example a simple well formed document instead of a
document including a DTD. This suggestion may improve the XSLT
recommendation's quality.

Didier PH Martin
mailto:martind at

Steve said:
You're still missing one thing for XSL to work :)

    <!ATTLIST xsl:stylesheet    id ID #REQUIRED>

The "#Style" fragment identifier can't find the element whose id is "Style"
it doesn't know which attributes are of type ID. Adding this ATTLIST will
the parser the needed information--it should work even for a non-validating

Regarding XML 1.0 validation, your new version is still not a "valid" XML
document--it's only well-formed. It's not sufficient to add xsl:stylesheet
the content model of <title>. You have to add separate <!ELEMENT>
for "xsl:stylesheet", "xsl:value-of", "html", "title", "body". You also have
add <!ATTLIST> definitions for all attributes that these new element types
Your DTD will be fairly large by the time you finish. If you want to embed
stylesheet in the document, you will probably want to give up being "valid",
accept being just "well-formed".

Another validity violation, not very serious but still a violation, is that
DOCTYPE element type should be "test" rather than "greeting".

For example, here's how the DOCTYPE of your document might look if you
wanted it to be completely valid--pardon my mistakes:

    <!DOCTYPE test [
        <!ELEMENT test (xsl:stylesheet, greeting)>
        <!ELEMENT greeting (#PCDATA)>
        <!ELEMENT xsl:stylesheet (html)>
        <!ELEMENT html (title, body)>
        <!ELEMENT title (#PCDATA)>
        <!ELEMENT body (xsl:value-of)>
        <!ELEMENT xsl:value-of EMPTY>
        <!ATTLIST xsl:stylesheet
                version CDATA #REQUIRED
                xmlns:xsl CDATA #REQUIRED
                id ID #REQUIRED>
        <!ATTLIST xsl:value-of
                select CDATA #REQUIRED>

Didier PH Martin wrote:

> Didier reply:
> You are right, the id attribute is missing in the stylesheet element. So
> right document should be:
> > <?xml version="1.0" encoding="UTF-8" ?>
> > <!DOCTYPE greeting [
> >   <!ELEMENT test (xsl:stylesheet, greeting)>
> >   <!ELEMENT greeting (#PCDATA)>
> > ]>
> > <?xml-stylesheet href="#Style" type="text/xsl"?>
> > <test>
> > <xsl:stylesheet version="1.0"
> >                 xmlns:xsl=""
> >                       id="Style">
> > <html>
> > <title>this is a test</title>
> > <body><xsl:value-of select="//greeting"></body>
> > </html>
> > </xsl:stylesheet>
> > <greeting>Hello, world!</greeting>
> > </test>
> So, the document, to be valid in accordance to the xml 1.0 recommendation,
> and if we want to parse it with validation, would have to be like above.

- Steve Dahl
sdahl at

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at
Archived as: and on CD-ROM/ISBN 981-02-3594-1
To unsubscribe, mailto:majordomo at the following message;
unsubscribe xml-dev
To subscribe to the digests, mailto:majordomo at the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at

More information about the Xml-dev mailing list