[jboss-dev-forums] [Design of JBossXB] - Re: Attributes problem
adrian@jboss.org
do-not-reply at jboss.com
Fri Mar 7 06:05:04 EST 2008
"alex.loubyansky at jboss.com" wrote : I am fine the structure of the schema. The bizarre thing is how it is treated during unmarshalling. I am for ease of use too and clarity. But I don't know what "correct" is :)
|
| We need to set attributes on a node that don't belong to that node. Ok. What is confusing to me is why only on CDATA and not others?
| Especially in the way you just wrote the schema: the cdata is a node on the same level as other elements. Why the attribute is lost on others?
|
| All I want to know is whether there is any other reason than "I don't need it in my example"?
Because that isn't what is happening. It's probably easier to see with the
property parsing.
I'll repeat everything again, because although you say you understand
you don't seem to be getting the key point. ;-)
| <property name="blah" replace="false">x</property>
|
Is really in our underlying model
| <property name="blah"><value replace="false">x</value></property>
|
The user can write it the long way if they want, but we give them the "short form" version.
In this case, we've got a specific type we can store the "replace" on,
so we don't need the wrapper hack because we can do it in our @XmlValue method.
In the generic case (like the map's key/value) we don't have this option so we need
to "synthesize it" during the parsing.
i.e. it goes something like:
| <map> new AbstractMapMetaData
| <entry> new MapEntry
| <key> new StringValueMetaData (SVMD)
| <list> oops not CDATA discard the SVMD and use AbstractListValueMetaData
|
We need to put the SVMD in place early otherwise we've got nothing to set
the attributes on (if there are any).
This is an artifcat of attributes are processed being processed
before the CDATA in the parsing.
NOTE: There really aren't any attributes on "key"
in our real model. They exist on the key in the xml just for ease of use.
Key isn't even a type it's a property of MapEntry which accepts an interface
which maps in xml to a group of posslble values including the synthetic
SVMD wrapping the CDATA.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134812#4134812
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4134812
More information about the jboss-dev-forums
mailing list