Hi,
I've played around with something similar in the past.
One way of doing this is to add a SAX filter in which you push and pop from a stack of elements, then implement your own error handler in which you generate an XPath from the stack. I was only trying to get XPaths and wasn't too concerned with generating particular error messages, but the error handler is then the place where you can decide which messages should belong to which errors.
It is a little more complex than this, since at any given depth you also need to count the occurrences of each element. I was dealing with some relatively simple documents, so this wasn't particularly onerous (I just had a map of element name vs number of occurrences for each level of nesting depth which I threw away when the level of nesting decreased), but you might need to look at some optimizations if you have very large/deeply nested documents.
John
> -----Original Message-----
> From: Torsten Curdt [mailto:[EMAIL PROTECTED]]
> Sent: 20 June 2002 13:47
> To: [EMAIL PROTECTED]
> Subject: Re: Error reporting from XML Schema and from
> Schematron (long)
>
>
> <snip/>
>
> > For that, we could use a common way of locating errors. I'm
> afraid that
> > getting the physical locations from Schematron is too
> difficult a task and
> > the result might not quite match the physical locations by
> Xerces. On the
> > other hand, Schematron can reliably produce 'logical'
> locations, something
> > like 'canonical XPath' to the node where the violation
> occurred. E.g.
> > '/root/a[1]/b[23]' meaning the 23rd 'b' child of the first
> 'a' child of
> > 'root'. (Things are more difficult in the presence of
> namespaces, but still
> > tractable.)
> >
> > How difficult would it be to extend Xerces to:
> > (i) Produce 'logical' locations in terms of 'canonical' XPaths
> > as described above.
> > (ii) Pass these locations to XMLErrorReporter.
> > Then I could set up a filtering XMLErrorReporter that would let me
> > gradually move violation reports from XML Schema to Schematron.
>
> God loves me - someone else wants exactly the same as I want :-))
> ...almost...
>
> I was always wondering why the xpath isn't passed with errors!!
>
> But I'd like go even a little further... I like to have some
> kind of an error
> object/facet whatever which tells what failed not only as a
> human readable
> message... so one can process it programmatically....
> --
> Torsten
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
The information transmitted by this e-mail message is intended solely for the use of the person to whom or entity to which it is addressed. The message may contain information that is privileged and confidential. Disclosure, dissemination, distribution, review, retransmission to, other use of or taking any action in reliance upon this information by anyone other than the intended recipient is prohibited. If you are not the intended recipient, please do not disseminate, distribute or copy this communication, by e-mail or otherwise. Instead, please notify us immediately by return e-mail (including the original message with your reply) and then delete and discard all copies of the message.
Although we have taken precautions to minimize the risk of transmitting viruses we nevertheless advise you to carry out your own virus checks on any attachment to this message. We accept no liability for any loss or damage caused by viruses.
