Valid XML document

Didier PH Martin martind at netfolder.com
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.

Cheers
Didier PH Martin
mailto:martind at netfolder.com
http://www.netfolder.com

----------
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"
if
it doesn't know which attributes are of type ID. Adding this ATTLIST will
give
the parser the needed information--it should work even for a non-validating
parser.

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
to
the content model of <title>. You have to add separate <!ELEMENT>
definitions
for "xsl:stylesheet", "xsl:value-of", "html", "title", "body". You also have
to
add <!ATTLIST> definitions for all attributes that these new element types
use.
Your DTD will be fairly large by the time you finish. If you want to embed
the
stylesheet in the document, you will probably want to give up being "valid",
and
accept being just "well-formed".

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

For example, here's how the DOCTYPE of your document might look if you
really
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
the
> 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="http://www.w3.org/1999/XSL/Transform"
> >                       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 goshawk.com



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





More information about the Xml-dev mailing list