Inserting optional complex types

X-Application Version: 3.1.2, 3.1.1
Tamino Version : 3.1.1
Platform : NT, Win2k, Solaris, …
WebContainer : Tomcat 3.3
JDK Version : 1.3.1

I have this schema definition
<xs:element name = “encumber” minOccurs = “0”>
xs:complexType
<xs:sequence minOccurs = “0”>
<xs:element name = “dimension” minOccurs = “0”>
xs:complexType
<xs:sequence minOccurs = “0”>
<xs:element name = “length” type = “xs:float” minOccurs = “0”></xs:element>
<xs:element name = “height” type = “xs:float” minOccurs = “0”></xs:element>
<xs:element name = “larghezza” type = “xs:float” minOccurs = “0”></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name = “weight” type = “xs:float” minOccurs = “0”></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>

If I use X-application bdm:create + bdm:edit and I leave empty the corresponding form fields I get a Tamino Store exeption which disappears if I put any valid value in those fields…
Why?
I would like to be able to leave these elements blank, this way I’m forced to insert a value into them…
Do you know why?
Paolo

X-Application does not support xs:float, all
xs:float values are handled like xs:string values.
As a consequence, your xs:float values are initialized to an empty string which is the default value for strings. If you try to store such an element in Tamino, you get a store exception because the empty string is not a valid xs:float value.

What you could do: change the definition to xs:string.

Alternatively, you could stick with xs:float and
add “value=‘0’” attributes to the respective html “input” tags to initialize manually initialize the input field to something valid. However, this would result in the same store exception if the used enters, e.g. a letter. (Which could be solved by adding some JavaScript to validate the input field before storeing the document …).

Michael

CAUTION: Please remove the “minOccurs=‘0’” from the inner sequence in your schema. It’s not actually needed since all elements in the sequence already have minOccurs=‘0’. Otherwise, Tamino or X-Application might, at some point, complain that the element is none-deterministic.

Software AG Germany, Darmstadt

Hi Paolo,

another way to solve your problem is using a default value:

<xs:element name = "length" type = "xs:float" default="0" minOccurs = "0"></xs:element>



If the field is left blank, ‘0’ is used as a default.
If you like to use the type xs:float there has to be a valid number as field value.

I hope either Michaels or my idea will solve your problem.

Thanks for your contribution.

Stefan Schwalm
Software AG, Darmstadt