users@jaxb.java.net

Tag name not allowed... but the same tag-name is in allowed set?

From: Steven Cummings <stevenc79_at_yahoo.com>
Date: Fri, 13 Jun 2003 14:03:34 -0700

Hello,

I'm successfully using JAXB to unmarshall entire documents
into their corresponding objects, but now I would like to
unmarshall just part of the document by passing a Node
(really an Element) to unmarshall. The element is not the
document-element. This gives me a strange (and yet amusing)
error:

javax.xml.bind.UnmarshalException
 - with linked exception:
[com.sun.msv.verifier.ValidityViolation: tag name
"identification" is not allowed. Possible tag names are:
<accessibility>,...,<identification>,...,<web>]
        at
javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:306)
        at
com.sun.xml.bind.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:156)
        at
edu.missouri.cecs.ideal.profiles.ProfileJaxbTest.main(ProfileJaxbTest.java:84)
Exception in thread "main"

My element-name ("identification") is decalred as a global
element in the schema, and as such you see it in the
allowed set. But on the very same line, JAXB tells me that
it is not allowed. Any idea of why this could happen?
Obviously it is something that is not-so-obvious or am I
just missing something?

This leads me to something I've been thinking about lately.
It would be nice if there were some "update" hooks in JAXB
that were more friendly to updating parts of documents and
node-structures. In my example above, I want to unmarshall
one part of a document and then update it back. Of course I
can do this, but it requires nothing short of loading the
whole DOM into memory, and seeking to that node myself for
manipulation.

What if JAXB allowed unmarshalling and marshalling methods
to specify XPath expressions to try to either find an
unmarshallable object at, or to write an marshallable
object to (replacing an existing instance, or updating it).
Is this very possible with the current RI? Is anybody else
thinking about it? Thanks!

/S


__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com