hi Lawrence ...

i wrote yesterday a second mail to the mailing list, stating that validate() returns false (my fault).

after thinking stuff through yesterday, i allready thought that the allowed "invalid" multiple calls to the the addNewValue is a "philosophical" thing, but working with validate() works now fine with me.

thx a lot for your answer,
sascha

Hi Sascha

XmlBeans deliberately allows you to set up invalid documents. When
constructing a document this is a positive feature - e.g. when you do
ValueDocument.Value v1 = p1.addNewValue();

what should be the value of the text within the newly created <value>
element? It is not yet assigned. We could assume that meant blank ("")
but what if the valid values for that element were an enumeration and ""
was invalid? There are many, many such constraints that you could put on
what's being constructed - being consistent with the maxOccurs is just
one of them - and so, no, no Exception should be thrown if you
incorrectly call addNewValue() too many times.

However when you call validate() this sort of thing should be caught. I
knocked up something based on the excerpt from a schema you included and
my validate() call correctly returned false.

Could you send your full schema and test code and I can investigate why
yours is returning true?

Thanks,

Lawrence

-----Original Message-----
From: Sascha Sadat-Guscheh [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 30, 2005 9:17 AM
To: dev@xmlbeans.apache.org
Subject: multiple values allowed, also if maxOccurance=1 ??

hi ..

i'm currently working with xml-beans and i found some "strange"
behaviour:
<xsd-snip>
<xs:element name="property">
       <xs:complexType>
           <xs:choice>
               <xs:element ref="value" minOccurs="0"
maxOccurs="unbounded"/>
               <xs:element ref="element" minOccurs="0"
maxOccurs="unbounded"/>
           </xs:choice>
       </xs:complexType>
</xs:element>
</xsd-snip>

i had this before and found out, that i only need one value/property,
so
i changed to xsd to

<xsd-snip>
<xs:element name="property">
       <xs:complexType>
           <xs:choice>
               <xs:element ref="value" minOccurs="0" maxOccurs="1"/>
               <xs:element ref="element" minOccurs="0"
maxOccurs="unbounded"/>
           </xs:choice>
       </xs:complexType>
</xs:element>
</xsd-snip>

as promised, all the getValueList / getValueArray disappeared but the
strange thing is, that this code is still valid:

PropertyDocument.Property p1 = a1.addNewProperty();
ValueDocument.Value v1 = p1.addNewValue();
v1.setStringValue("my new TITLE");
ValueDocument.Value v2 = p1.addNewValue();
v2.setStringValue("my new TITLE sec value");

i expected the second p1.addNewValue() to throw an Exception. also, if
i
run the validate() method on the xml-objects, everythings
seems to be ok, although the document should be invalid (by xsd-
definition)

any ideas?

thx, sascha

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



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



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

Reply via email to