Windy,

Since you mentioned DOMLocator I assume you're doing the validation using
normalizeDocument(). When you receive a DOMError during validation you can
extract the line/column information from the related node [1] attached to
the DOMLocator. The user data attached to the node is out of band
information which the implementation has no knowledge of so you'll still
get -1 from getColumnNumber() and getLineNumber() if you invoke those
methods.

Thanks.

[1]
http://xerces.apache.org/xerces2-j/javadocs/api/org/w3c/dom/DOMLocator.html#getRelatedNode()

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

"Windchime" <[EMAIL PROTECTED]> wrote on 12/19/2007 02:28:48 PM:

> Michael,
>
> Thanks, but how does this interact with the DOMLocator?  Or is the
default
> schema error message even using the DOMLocator?
>
> -Windy
>
> > -----Original Message-----
> > From: Michael Glavassevich [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, December 19, 2007 9:10 AM
> > To: j-users@xerces.apache.org
> > Subject: RE: Avoiding DOM Reparse
> >
> > Hi Windy,
> >
> > There's a sample that comes with Xerces called dom.DOMAddLines [1]
which
> > shows how you can add line/column information to the DOM using
> > Node.setUserData() [2] and read it back with Node.getUserData() [3].
Note
> > that this requires an extension to the DOM parser implementation.
There's
> > no standard way of doing this and if you start making modifications to
the
> > DOM after loading it the line/column information you initially stored
> > gradually becomes meaningless.
> >
> > Thanks.
> >
> > [1] http://xerces.apache.org/xerces2-j/samples-dom.html#DOMAddLines
> > [2]
> > http://xerces.apache.org/xerces2-
> >
j/javadocs/api/org/w3c/dom/Node.html#setUserData(java.lang.String,%20java.
> > lang.Object,%20org.w3c.dom.UserDataHandler)
> > [3]
> > http://xerces.apache.org/xerces2-
> > j/javadocs/api/org/w3c/dom/Node.html#getUserData(java.lang.String)
> >
> > Michael Glavassevich
> > XML Parser Development
> > IBM Toronto Lab
> > E-mail: [EMAIL PROTECTED]
> > E-mail: [EMAIL PROTECTED]
> >
> > "Windchime" <[EMAIL PROTECTED]> wrote on 12/19/2007 11:21:11 AM:
> >
> > > Michael,
> > >
> > > Thanks much, this worked exceptionally well.  One minor issue though
is
> > the
> > > reported line numbers are no longer there (-1).  Do I need some
setting
> > > while loading the DOM?
> > >
> > > Also, assuming the line numbers are actually determined, how would I
> > access
> > > them from the DOM (independent of the schema validation issue)?
> > >
> > > -Windy
> > >
> > > > -----Original Message-----
> > > > From: Michael Glavassevich [mailto:[EMAIL PROTECTED]
> > > > Sent: Tuesday, December 11, 2007 10:24 AM
> > > > To: j-users@xerces.apache.org
> > > > Subject: Re: Avoiding DOM Reparse
> > > >
> > > > Hi Windy,
> > > >
> > > > Before calling normalizeDocument() you should be able to set the
> > > > "http://apache.org/xml/properties/internal/grammar-pool"; property
on
> > the
> > > > DOMConfiguration with your grammar pool. Alternatively you could
use
> > the
> > > > JAXP Validation API [1]. If you pass the PSVI-aware version of the
DOM
> > to
> > > > the Validator [2] as both the Source and Result it will annotate
your
> > DOM
> > > > with PSVI.
> > > >
> > > > Thanks.
> > > >
> > > > [1]
> > > > http://xerces.apache.org/xerces2-
> > > > j/javadocs/api/javax/xml/validation/package-summary.html
> > > > [2]
> > > > http://xerces.apache.org/xerces2-
> > > >
> >
j/javadocs/api/javax/xml/validation/Validator.html#validate(javax.xml.tran
> > > > sform.Source,%20javax.xml.transform.Result)
> > > >
> > > > Michael Glavassevich
> > > > XML Parser Development
> > > > IBM Toronto Lab
> > > > E-mail: [EMAIL PROTECTED]
> > > > E-mail: [EMAIL PROTECTED]
> > > >
> > > > "Windchime" <[EMAIL PROTECTED]> wrote on 12/11/2007 12:30:30 PM:
> > > >
> > > > > I am reading lots of XML documents that need schema validation.
> > > > However,
> > > > I
> > > > > don't know what the schema (actually grammar pool) looks like
until
> > long
> > > > > after the documents are read.  Finally, I want to have full
access
> > to
> > > > the
> > > > > PSVI information.
> > > > >
> > > > > What I would like to know is, is there any way to perform the
schema
> > > > > validation without reparsing the XML.  The reparse causes two
> > problems:
> > > > > 1) Takes time
> > > > > 2) All cached Element references must be re-cached
> > > > >
> > > > > The code that I have generally works just fine, except that I
must
> > > > reparse
> > > > > the DOM a second time once the grammar has been determined.
> > > > >
> > > > > In priority order, it would be great if I could:
> > > > >
> > > > >    * Somehow associate the grammar pool and then just call
> > > > > normalizeDocument() [ I already have a PSVIDocument using the
> > > > > 'http://apache.org/xml/properties/dom/document-class-name'
property
> > ]
> > > > >
> > > > >    * Use an input source that would preserve the original DOM
> > > > >
> > > > >
> > > > >
> > > > > Thanks much in advance,
> > > > >
> > > > >
> > > > > -Windy
> > > > >
> > > > >
> > > > >
--------------------------------------------------------------------
> > -
> > > > > 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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to