Mike, Got it. Many Thanks again. Lynn
-----Original Message----- From: Michael Glavassevich [mailto:[EMAIL PROTECTED] Sent: Thursday, April 17, 2008 9:29 AM To: j-users@xerces.apache.org Subject: RE: xerces does not validate dtd even though it is set to true Hi Lynn, Register an ErrorHandler [1] with the parser and throw an exception from the error() method if that's the behaviour you want. Thanks. [1] http://xerces.apache.org/xerces2-j/javadocs/api/org/xml/sax/ErrorHandler .html Michael Glavassevich XML Parser Development IBM Toronto Lab E-mail: [EMAIL PROTECTED] E-mail: [EMAIL PROTECTED] "Huynh, Lynn T." <[EMAIL PROTECTED]> wrote on 04/17/2008 09:10:26 AM: > Mike, > Yes, I saw the problem. > I do get the error, but the problem is the parser.parse does not throw > any error, so I could not catch the exception. I need to be able to > catch this error. Is there anyway I get get the actual error message > instead of just printing it out to the console? > > > -----Original Message----- > From: Michael Glavassevich [mailto:[EMAIL PROTECTED] > Sent: Wednesday, April 16, 2008 3:41 PM > To: j-users@xerces.apache.org > Subject: RE: xerces does not validate dtd even though it is set to > true > > Hi Lynn, > > The document you attached is different than the one you originally > posted to the list. > > Specifically, <LABEL A3=""> --> <LABEL A1="Attribute Text" A3=""> > which contains the required attribute. You also changed the DTD, so no > wonder you're not getting any errors. > > Thanks. > > Michael Glavassevich > XML Parser Development > IBM Toronto Lab > E-mail: [EMAIL PROTECTED] > E-mail: [EMAIL PROTECTED] > > "Huynh, Lynn T." <[EMAIL PROTECTED]> wrote on 04/16/2008 02:30:56 > PM: > > > Mike, > > Attached the Counter sample, where I modified the DEFAULT_VALIDATION > > = > > > true, so I didn't have to pass in the options. And I ran it with > > the attached xml file and the label.dtd. > > Plus, I am using xerces 2_9_1 package. > > Just with these three files, I get back the result of: > > > > Temp.xml: 63 ms (3 elems, 3 attrs, 0 spaces, 232 chars) And no error > > caught. > > > > > > -----Original Message----- > > From: Michael Glavassevich [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, April 16, 2008 2:22 PM > > To: j-users@xerces.apache.org > > Subject: RE: xerces does not validate dtd even though it is set to > > true > > > > Hi Lynn, > > > > Likely there's something else going on here which you haven't > mentioned. > > Not sure what to suggest since I can't reproduce it with what you > > posted. > > > > Thanks. > > > > Michael Glavassevich > > XML Parser Development > > IBM Toronto Lab > > E-mail: [EMAIL PROTECTED] > > E-mail: [EMAIL PROTECTED] > > > > "Huynh, Lynn T." <[EMAIL PROTECTED]> wrote on 04/16/2008 > > 01:55:12 > > PM: > > > > > Hi Mike, > > > I thought so too. It is hard to believe that this is happening. > > > And thought that I could have done something wrong. > > > > > > I'm testing with sax.Counter sample and not able to see the error > > > message either. > > > I turned on the validation in the Counter sample as well. > > > > > > > > > -----Original Message----- > > > From: Michael Glavassevich [mailto:[EMAIL PROTECTED] > > > Sent: Wednesday, April 16, 2008 11:22 AM > > > To: j-users@xerces.apache.org > > > Subject: Re: xerces does not validate dtd even though it is set to > > > true > > > > > > Hi Lynn, > > > > > > Hard to believe that Xerces isn't reporting this error. When I try > > > your example with the sax.Counter sample I get: > > > > > > [Error] label.xml:4:14: Attribute "A1" is required and must be > > > specified for element type "LABEL". > > > > > > Validation errors are non-fatal. Are you sure that you're > > > registering an ErrorHandler and not ignoring the errors reported > > > to > it? > > > > > > Thanks. > > > > > > Michael Glavassevich > > > XML Parser Development > > > IBM Toronto Lab > > > E-mail: [EMAIL PROTECTED] > > > E-mail: [EMAIL PROTECTED] > > > > > > "Huynh, Lynn T." <[EMAIL PROTECTED]> wrote on 04/16/2008 > > > 10:13:32 > > > AM: > > > > > > > Hi, > > > > In my DTD, I have one of the attribute name as a required > attribute. > > > > However, when I used it and do not have it in the xml, Xerces > > > > does not return any error. > > > > I have factory.setValidating(true) and > > > > xmlReader.setFeature("http://xml.org/sax/features/validation", > > true). > > > > > > > > Here is the sample DTD: > > > > <!ELEMENT LABEL ANY> > > > > <!ATTLIST LABEL A1 CDATA #REQUIRED> <!ATTLIST LABEL A3 CDATA ""> > > > > <!ENTITY title "The title"> <!ELEMENT FIRST (#PCDATA)> <!ATTLIST > > > > FIRST A2 CDATA ""> <!ENTITY subtitle "my subtitle"> <!ELEMENT > > > > SECOND (#PCDATA)> <!ELEMENT THIRD (#PCDATA)> > > > > > > > > Sample XML, please note LABEL does not have the required A1 > > attribute: > > > > <!DOCTYPE LABEL SYSTEM "label.dtd"> > > > > <!-- This is a comment --> > > > > <?xml-stylesheet type="text/xml"?> <LABEL A3=""> > > > > $3.99 > > > > <!-- This is another comment --> > > > > <![CDATA[ << CDATA >> ]]> > > > > &title; > > > > <FIRST A2="Or &subtitle;"/> > > > > <SECOND/> > > > > </LABEL> > > > > > > > > Thanks in advance for any input. > > > > Lynn > > > > > > > > > > > > THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE > > > > PROPRIETARY MATERIAL and is thus for use only by the intended > > > > recipient. If you received this in error, please contact the > > > > sender and delete the e-mail and its attachments from all > > > > computers > > > > > > > > ---------------------------------------------------------------- > > > > -- > > > > -- > > > > - 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] > > > > > > > > > ------------------------------------------------------------------ > > > -- > > > - 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] > > > > [attachment "label.dtd" deleted by Michael Glavassevich/Toronto/IBM] > > [attachment "Temp.xml" deleted by Michael Glavassevich/Toronto/IBM] > > [attachment "Counter.java" deleted by Michael > > Glavassevich/Toronto/IBM] > > -------------------------------------------------------------------- > > - 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] > > > --------------------------------------------------------------------- > 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]