You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Lawrence Jones <lj...@bea.com> on 2006/04/04 02:05:07 UTC

RE: Inheritance by Restriction: found a Bug ?

Hi Frank

I'm not sure whether this was a bug or an old policy decision. But I
agree that the code that currently gets generated does look at little
odd in terms of usability and could be better. So I've raised a JIRA
(see http://issues.apache.org/jira/browse/XMLBEANS-261) to track the
issue and see if we can do better.

There are some other issues involved:

Even if you don't enable the setter you can still use the cursor API to
insert such an element, or simply parse a file with that element in it.
What should the getter return then? 

If the getter is returning null, but using xmlText() or toString() you
can output the element then that looks odd too - so should we extend it
such that calling xmlText() removes any such element? But that would be
odd too?

What if someone inherits from the restricted type by extension and
"re-enables" the elements you removed?

Anyway, as I say, broadly I agree with you. I've logged the above points
in the JIRA and we can go from there.

Cheers,

Lawrence

> -----Original Message-----
> From: Frank Steimke [mailto:f-steimke@berger-und-steimke.de]
> Sent: Friday, March 31, 2006 8:30 AM
> To: user@xmlbeans.apache.org
> Subject: Inheritance by Restriction: found a Bug ?
> 
> 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: user-unsubscribe@xmlbeans.apache.org
> For additional commands, e-mail: user-help@xmlbeans.apache.org

_______________________________________________________________________
Notice:  This email message, together with any attachments, may contain
information  of  BEA Systems,  Inc.,  its subsidiaries  and  affiliated
entities,  that may be confidential,  proprietary,  copyrighted  and/or
legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient,
and have received this message in error, please immediately return this
by email and then delete it.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: user-help@xmlbeans.apache.org