Thanks Volker!
Indeed you're right, my DTD was wrong.
http://www.w3.org/TR/REC-xml#NT-Mixed
I should not trust Wrox books (or french translations, I don't know...) from
which the example was extracted..
By the way, could you explain me please the difference between
xercesImpl.jar and xml-apis.jar.
My self experience:
import org.apache.xerces.parsers.DOMParser;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
import java.io.IOException;
public class DOMParserDemo2 {
public static void main (String args[]){
DOMParser parser = new DOMParser();
Document doc = null;
try {
parser.parse("CatalogueLivres.xml");
doc = parser.getDocument();
} catch (IOException ie){
System.out.println("Could not read file.");
} catch (SAXException e) {
System.out.print("Could not create Document: ");
System.out.println(e.getMessage());
}
}
}
will compile well with xercesImpl.jar in classpath but will throw an
exception at runtime:
java.lang.NoClassDefFoundError: org/w3c/dom/range/DocumentRange
All compiles and runs well with xml-apis.jar on my classpath.
why this happens?
I would be very grateful if you may shed light on this topic..
Regards,
Cyril.
----- Original Message -----
From: "Volker Witzel" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 06, 2003 1:15 PM
Subject: Re: validation against DTD
> Dear Cyril,
>
> the DTD is wrong. AFAIK mixed content is only possible with a choice,
> thus the DTD should look like:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE CatalogueLivres [
> <!ELEMENT CatalogueLivres (#PCDATA | X | Y)*>
> <!ELEMENT X EMPTY>
> <!ELEMENT Y EMPTY>
> ]>
> <CatalogueLivres>
> toto
> <X/>
> <Y/>
> </CatalogueLivres>
>
>
> BTW: I have never understood, where mixed content could be unavoidable
> and/or useful. So, are you sure you want it that way?
>
> Regards,
> Volker.
>
> cyril vidal wrote:
>
> > Dear all,
> >
> > I would like to use Xerces in order to validate a very simple document
> > against a DTD:
> >
> > Here's my XML document to be validated:
> > <?xml version="1.0" encoding="iso-8859-1"?>
> >
> > <!DOCTYPE CatalogueLivres
> > [
> > <!ELEMENT CatalogueLivres (#PCDATA,X,Y)>
> > <!ELEMENT X EMPTY>
> > <!ELEMENT Y EMPTY>
> > ]>
> > <CatalogueLivres>
> > toto
> > <X/>
> > <Y/>
> > </CatalogueLivres>
> >
> > So, CatalogueLivres is supposed to contain both PCDATA and empty
> > elements X and Y and it seems to be the case...
> >
> > But during validation, i receive the following error message:
> > [FATAL Error] CatalogueLivres.xml:5:38: D�claration of element
> > "CatalogueLivres" must contain either a character ')' (??) or an element
> > type.
> >
> > When i change the doctype so that CatalogueLivres contains only PCDATA
> > or elements, it runs well...
> >
> > Could someone explain me where I am wrong, please?
> > Thanks in advance,
> > Cyril.
>
>
>
>
> ---------------------------------------------------------------------
> 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]