Hi Ajay,

The short answer to your question is no. The DOM API provides no methods
for getting line/column numbers so they're not available to the validator
when DOM is the input. There are some non-standard ways of adding
line/column info to DOM nodes using user data (introduced in DOM Level 3).
There's a sample [1] that ships with Xerces-J that shows how you can do it.
The validator won't read this info but your application could read it from
the current element node [2] when an error is reported. Note that if you've
mutated the DOM after loading it the line/column numbers may become
misleading/meaningless.

Thanks.

[1] http://xerces.apache.org/xerces2-j/samples-dom.html#DOMAddLines
[2]
http://xerces.apache.org/xerces2-j/properties.html#dom.current-element-node

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]

ajay bhadauria <[EMAIL PROTECTED]> wrote on 11/04/2008 05:13:27 PM:

> Michael,
>
> Thanks for response. I have gone through all the links which you
> have provided. It looks like that there is no straight way to get the
xpath.
>
> If I get the line number during validation error that will be great.
>
> I know that DOM level 2 does not give line number during validation
error.
>
> How can I get the line number when validation error takes place ?
>
> SAXSource and StreamSource give line number but I want only with
> DOM. So is there any way I can get the line number during validation
> error ? Does DOM level 3 give line number ?
>
> Thanks
> Ajay
>
>
> --- On Fri, 10/31/08, Michael Glavassevich <[EMAIL PROTECTED]> wrote:
>
> > From: Michael Glavassevich <[EMAIL PROTECTED]>
> > Subject: Re: how to xpath when schema validation fails.
> > To: [EMAIL PROTECTED]
> > Cc: [EMAIL PROTECTED]
> > Date: Friday, October 31, 2008, 9:34 PM
> > Hi Ajay,
> >
> > There's no reliable way to do that. This topic has come
> > up on the Xerces
> > mailing list several times. See one of my responses here
> > [1].
> >
> > Thanks.
> >
> > [1]
> > http://marc.info/?l=xerces-j-user&m=107375672210434&w=2
> >
> > Michael Glavassevich
> > XML Parser Development
> > IBM Toronto Lab
> > E-mail: [EMAIL PROTECTED]
> > E-mail: [EMAIL PROTECTED]
> >
> > ajay bhadauria <[EMAIL PROTECTED]> wrote on
> > 10/31/2008 11:55:59 AM:
> >
> > > Hi,
> > >
> > > I need help.
> > >
> > > I am doing xml document validation against schema
> > using xalan 2.7.1.
> > > I am providing dom to validate API of xalan 2.7.1.
> > >
> > > So when dcoument validation fails on some element of
> > the xml
> > > document , how do we construct xpath from root element
> > of the
> > > document to the element where error occuurred.
> > >
> > >
> > > Thanks a lot.
> > >
> > > Ajay Bhadauria

Reply via email to