Hi,

At my Job, we try to design XML-based messages for eGovernment. We have
developed a complex Datamodel. Messageparts are modelled by some general
complexTypes. We are using JAVA and XMLBeans for reference implementations.
Now, we want to use specialized dataTypes which are derived by restriction
from the general Types. Thats why i am particular interested in "inheritancs
by restriction".

Maybe i have found a bug. 

The following simplified Example is stolen from "The Design of XMLBeans
(Part 3)" by davidbau.com. I tried with both Version 1.0.4 and 2.1 of XML
Beans.

I have a simple schema with a complexType "baseType" and three Elements
"first, "middle" (optional) and "last". (All three of type xsd:string).
I have a type "restrictedType", derived by restriction from baseType. Onle
difference: the "middle" Element is completely removed. I am only interested
in the Access to the "middle" Element in the restricted type.

When i compile the types, then I would expect (accoring to the paper cited
above) for the restrictedType:
- there is a "setMiddle" Method (because RestrictedType inherits it from
BaseType), but effect ist unclear. Maybe silenty ignored?
- there is a "getMiddle" Method (because RestrictedType inherits it from
BaseType), but it should allways return NULL

I made the test with two ways to assign a value to the "middle" Element:
- Simple Assignment, e. g.  restricted.setMiddle("Middle");
- Copy via DOM: construct a baseType, assign a value to its "middle", and
set restricted = RestrictedType.Factory.parse(base.newDomNode());


Running with Version 1.0.4 gives for simple Assignment
- setMiddle: NullPointerException !
- getMiddle: Success, value = NULL (sure, because it was not set)
And for the copy via DOM:
- parse(base.newDomNode()) works fine,
- getMiddle: Success, value is what was assigned to "middle" from the
baseType

Running with Version 2.1 gives for simple Assignment
- setMiddle: Success
- getMiddle: Success, value = the value that was assigned!
And for the copy via DOM:
- parse(base.newDomNode()) works fine,
- getMiddle: Success, value is what was assigned to "middle" from the
baseType

To make things worse, i get a lot of RuntimeErrors when i try to access
"removed" Elements from restricted Types in my real-life Schema from
eGovernment. It is something like "java.lang.ClassCastException:
org.apache.xmlbeans.impl.values.XmlAnyTypeImpl". Unfortunately, I was unable
to reproduce this with the simplified example given above.

As far as i understand, under no circumstances "Inheritance by restriction"
is implemented in a way so that the requirements of the "Design" - Paper are
fulfilled. Runtime Errors make the "Restriction" Feature very unstable for
XMLBeans. 

Is this a bug, or did you make other decisions, or did i get something
wrong? 

Thank you
Frank Steimke


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

Reply via email to