You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by "Ralf I. Pfeiffer" <rp...@us.ibm.com> on 2000/02/28 23:10:12 UTC

Re: [PROPOSAL] new LocatorImpl methods and/or SchemaMessageschanges

Getting Nodes when errors occur:
-----------------------------------

Using the DOMParser, another approach is to get the property:
parser.getProperty("http://apache.org/xml/features/dom/current-element-node");

which will return the current Element Node at the point of error.

You must also:
parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion",
false);
(The DOMParser cannot defer node creation but  return random nodes in error.)

If you wanted to store/take action on all Element Nodes in error, you could do
so in an
ErrorHandler, and making this call in error, warning and fatalError.

Also you may be interested to keep the parser going on fatalError, so:
parser.setFeature("http://apache.org/xml/features/continue-after-fatal-error",
true);

Have fun,
-Ralf Pfeiffer


Jeffrey Rodriguez wrote:

> Even tough I see how this can be more useful I hate to think about
> the performance implications.
> With the line and column information all we are doing is just
> reporting the scanner information since we are using the
> org.apache.xerces.readers.DefaultEntityHandler getLineNumber()
> and getColumnNumber() methods.
>
> What you are proposing is modifying the implementation of the
> Locator interface ( LocatorImpl) and maybe modifying the
> org.apache.xerces.framework.XMLParser reportError method.
> By the way all the error error reporting originates here at reportError
> method of class XMLParser.
>
> Do you have an implementation?
>
> Thanks,
>               Jeffrey Rodriguez
>               XML Development
>               IBM Cupertino
>
> >From: kito_mann@prusec.com
> >Reply-To: xerces-dev@xml.apache.org
> >To: xerces-dev@xml.apache.org
> >Subject: [PROPOSAL] new LocatorImpl methods and/or SchemaMessages changes
> >Date: Fri, 25 Feb 2000 12:37:24 -0500
> >
> >One of the things I need from the schema implementation is details on
> >exactly where an error occurs (over and above the line number). For
> >instance, the message "[Error] :5:66: Incorrect datatype: A is not a
> >boolean." isn't too helpful if I can't access the document via the line
> >number. Basically, what I'd like is the name of the element and (if
> >applicable) the attribute that's causing the problem. As far as I can
> tell,
> >there are two ways to do this: (1) modify the error messages and the
> >methods that call the error reporting methods, and/or (2) modify
> >LocatorImpl() so that it has setElementName(), getElementName(),
> >setAttributeName(), and getAttributeName() methods (and update these
> values
> >accordingly).
> >
> >Does anyone have input on what would be the preference (or if neither of
> >them are appealing)?
> >
> >Kito D. Mann
> >Virtua Communications Corp
> >
> >
>
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com

--
<person name="Ralf I. Pfeiffer"
 loc="IBM JTC, Cupertino, CA"
 email1="rpfeiffe@us.ibm.com"
 email2="rpfeiffe@apache.org"
/>