Your XML file and the Dtd is correct . Your dtd correctly says that there
will be a name tag inside the content tag. So the parser is correctly not
complaining.

Enjoy.

Anish

 -----Original Message-----
From:   Amedeo Farello [mailto:[EMAIL PROTECTED] 
Sent:   Thursday, August 30, 2001 8:55 AM
To:     xerces-j-user
Subject:        DTD validation

Hi,

I have just started working with DTDs and I feel I am getting strange
results
from validation. Since I am not an XML expert, I hope someone can help.

I will use a minimal example:

given the following 'test.dtd':

<?xml encoding="UTF-8"?>
<!ELEMENT container (content)>
<!ELEMENT content (name)>
<!ELEMENT name (#PCDATA)>

and the following 'test.xml':

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE container SYSTEM "test.dtd">

<container>
    <name>Cat</name>
    <content>
        <name>Dog</name>
    </content>
</container>

I would expect, from what I have understood about DTDs (which could not be
enough, I admit) that a validating parser should raise an exception
indicating
the presence of a <name> element outside of a <content> element. Instead
Xerces
parses such a file without problems.

I have tried inserting unknown tags and they are correctly refused, so I
believe the parser is using the right DTD file. Besides, if the DTD file is
not
where it should be, the parser complains.

I am using Xerces 1.4.2 and SAX2. All error handling is perfectly functional
(I've done a number of tests), it's just that the parser seem to find this
construct correct.

Am I wrong to believe that my example should be considered invalid?

Thanks in advance for any help.

Amedeo




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to