users@jaxb.java.net

Re: Line-numbers of already parsed elements

From: Thomas Behrends <tbehrends_at_instantolap.de>
Date: Wed, 07 May 2003 22:23:58 +0200

We use JAXB for parsing complex configuration-files which can't be
validated by using XML-schemes only (for example, some attributes
contain formula-expression which have to be checked to and depend on
some database-content).When our users create these configurations,
they'd like to have detailed position-informations in their
error-messages. So we need to provide error-messages for invalid
attributes of already parsed elements.

For example it would be helpful if unmarshalled elements had a method
like "getLocator()" in their Implementation-class which returns their
locator (set when the unmarshaller of a single element was created or
null, if there was no unmarshalling before).

Then we could use the method for our error messages - even if a
class-cast would be needed to access the implementation class.




Kohsuke Kawaguchi wrote:

>>is there any practical way to find out the line-number of a already
>>parsed and bound element? Some of my validations can be only be
>>performed AFTER the complete document is parsed and my error-messages
>>can't supply a line-number.
>>
>>
>
>I can see the needs. But I'm afraid there's no easy way to do what you
>want.
>
>In general this seems like a hard problem, since one object is typically
>unmarshaled from an area of an input document, so there's no easy way to
>point to a particular element/attribute and say that's where it comes
>from. So I guess you are looking at some approximation of that.
>
>
>I'd appreciate if you could explain more about what you'd like to see.
>Then we might be able to work out something.
>
>
>regards,
>--
>Kohsuke KAWAGUCHI 408-276-7063 (x17063)
>Sun Microsystems kohsuke.kawaguchi_at_sun.com
>
>
>