You could track XPath via the SAX events and look (using regular expressions based on the XML schema messages obtained from XERCES's resource bundle) for schema validation errors that apply to elements and/or attributes and determine the XPath to a failure that way. It can be done (we've done this) - at least for the types of errors we need to cover. Commonly, errors for attributes are reported immediately prior to the startElement event to which they apply (at least in the version of XERCES we use) while errors in element content are reported after the startElement event and before the endElement event. However, it's a simple task to determine this for yourself. Hope that helps, Phil :n)
-----Original Message-----
From: Michael Glavassevich [mailto:[EMAIL PROTECTED]
Sent: Sat 10/01/2004 17:45
To: [EMAIL PROTECTED]
Cc:
Subject: Re: XS Validation handling
For the record we don't support SAX's dom-node property. There is no
DOM
tree backing the SAX event stream. It's generated from XNI. You'd have
to keep your own stack to track the context (and something else to keep
track of siblings) to generate an XPath expression.
The tricky part is figuring out the context of the error. None is
provided
so you need to make some assumptions (this also applies to the DOM while
it's being built as well) about event order and where an error is
reported
in the stream. This topic came up last year [1]. I still feel that
generating an XPath given the current APIs cannot be done reliably,
though
you can probably get a good approximation for some errors (like with
simple types).
[1] http://marc.theaimsgroup.com/?l=xerces-j-user&m=106182672730969&w=2
On Sat, 10 Jan 2004, Phil Weighill-Smith wrote:
> I think the XERCES SAX and DOM parsers (you could perhaps use the
latter
> for your DOM validation from your other query?) have some properties
> that could be of use:
>
> http://xml.org/sax/properties/dom-node (SAX parser) and
> http://apache.org/xml/properties/dom/current-element-node (DOM
parser).
>
> See http://xml.apache.org/xerces-j/properties.html. Once you've got
the
> node you should be able to determine an XPath for it. You may also
need
> to determine if the error relates to an attribute of that node by
> interpreting the actual error you get from the parser...
>
> Phil :n)
>
> On Sat, 2004-01-10 at 00:50, Jan Pernica wrote:
>
> > Hi everybody
> >
> > I have XML and XS schema. Let's assume that the validated XML is
valid XML
> > (well formed). But there are XS validation errors like theese
> > [Error] test.xml:10:25: cvc-pattern-valid: Value '6910018dd093' is
not
> > facet-valid with respect to pattern '[0-9]{9,10}' for type 'RCType'.
> > [Error] test.xml:10:25: cvc-type.3.1.3: The value '6910018dd093' of
element
> > 'rc' is not valid.
> > [Error] test2.xml:80:44: cvc-attribute.3: The value '9'0'1.01.2003'
of
> > attribute 'datVzniku' on element 'poistenie' is not valid with
respect to
> > its type, 'DatumType'.
> >
> > The question is: how do I get Xpath to element or attribute with an
error?
> >
> > Thanks for any hints
> >
> > Regards
> >
> > Jan Pernica
> > mailto:[EMAIL PROTECTED]
> > http://www.pernica.org
> >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
---------------------------
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<<winmail.dat>>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
