I got a direct mail with a question about why the statement below causes SAXNotRecognizedException out of the box. I decided to post it back to the list in case anyone else experiences this.
Validator.getProperty( "http://apache.org/xml/properties/dom/current-element-node"); This property does not seem to be supported by the XML parser that comes with your JRE. You need to use the Xerces parser directly. Download binary distribution of Xerces and put the jar files in some directory. Then tell Java launcher that that directory is an "endorsed standards" directory, like this: > java -Djava.endorsed.dirs=<PATH TO DIR WITH XERCES JAR FILES> TestCurrentNode Then it should work. Alex. ________________________________ From: ajay bhadauria <[EMAIL PROTECTED]> To: Alex Talis <[EMAIL PROTECTED]> Sent: Monday, November 17, 2008 2:43:52 PM Subject: Re: How to get node when validation fails Hi Alex, Thanks for quick response I used the property by I am getting the exception. Could you please suggest what I am doing wrong ? How did you implement ? I am attaching unit program just to take a look ? Progrma started instance error org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'Doc:Id1'. One of '{"urn:swift:xsd:swift.eni$camt.028.001.02":Id}' is expected. org.xml.sax.SAXNotRecognizedException: http://apache.org/xml/properties/dom/current-element-node Program ended Thanks a lot ! --- On Tue, 11/18/08, Alex Talis <[EMAIL PROTECTED]> wrote: > From: Alex Talis <[EMAIL PROTECTED]> > Subject: Re: How to get node when validation fails > To: [EMAIL PROTECTED] > Date: Tuesday, November 18, 2008, 4:06 AM > Hi Ajay, > > Yes, the question was actually answered in the thread. > Here's the response so that you don't have to look: > > --------------------------- > The current element node being visited by the Validator can > be queried [1] from your error handler by calling back into > it with getProperty() [2]. > > Thanks. > > [1] > http://xerces.apache.org/xerces2-j/properties.html#dom.current-element-node > [2] > http://xerces.apache.org/xerces2-j/javadocs/api/javax/xml/validation/Validator.html#getProperty(java.lang.String) > --------------------------- > > So inside your error handler, you can make a call to the > validator like this: > > Element el = > (Element)validator.getProperty(http://apache.org/xml/properties/dom/current-element-node); > > Good luck! > > > > > ________________________________ > From: ajay bhadauria <[EMAIL PROTECTED]> > To: Alex Talis <[EMAIL PROTECTED]> > Sent: Monday, November 17, 2008 2:29:27 PM > Subject: How to get node when validation fails > > Hi Alex, > > I saw your question in the apache mailing list. I am also > having the same problem. > > How do I get the node when validation fails ? would you > able to solve the problem ? If yes, could you please tell me > what should I do so that I can get the node where validator > throws error ? > > > Thanks > Ajay