Federico,

The schema looks fine, if you look closely at SubInfo type def:

<xs:complexType name="SubInfo">
                <xs:complexContent>
                        <xs:restriction base="Info">
                                <xs:sequence>
                                        <xs:element name="Nome" 
type="Testo70Custom"/>
                                </xs:sequence>
                        </xs:restriction>
                </xs:complexContent>
        </xs:complexType>
        <xs:complexType name="Info">
                <xs:sequence>
                        <xs:element name="Nome" type="Testo140" minOccurs="0"/>
                </xs:sequence>
        </xs:complexType>
        <xs:simpleType name="Testo70Custom">
                <xs:restriction base="Testo140">
                        <xs:maxLength value="70"/>
                </xs:restriction>
        </xs:simpleType>
        <xs:simpleType name="Testo140">
                <xs:restriction base="xs:string">
                        <xs:minLength value="1"/>
                        <xs:maxLength value="140"/>
                </xs:restriction>
        </xs:simpleType>

SubInfo is a restriction of type Info, i.e. it has to have a property called 
Nome of type Testo140.
But in the same type the element Nome inside the SubInfo sequence is declared 
of type Testo70Custom, which is fine because Testo70Custom is a subtype of 
Testo140.

This is a case where java rules and schema rules don't match fully. But if 
you're a little careful everything works fine,  make sure that you use 
SubInfo.xsetNome() only with objects of type Testo70Custom.

Cezar


On Nov 5, 2013, at 10:29 AM, Federico Rossetti <federico.rossetti...@gmail.com> 
wrote:

> Hi all
> 
> 
> 
> i have a starting xsd no editable, from which to generate the Java source 
> code with XMLBeans. My problem is on the generated java class SubInfo.java.
> 
> 
> 
> In the xsd, the element “Nome”, child of the element “SubInfo”, has as type 
> “Testo70Custom”, but in the generated java code the type is “Testo140”. Is 
> the xsd poorly written the problem? Or is the process of code generation the 
> problem?
> 
> 
> 
> The correct type is important because in my java code – client side – I use 
> it to get some attributes of the xsd elements (like max length of string, to 
> truncate strings in surplus) from the schemaytpe in order to perform the 
> validation before sending out the message. If the type is wrong, I could send 
> erroneous messages.
> 
> 
> 
> In binary file .xsb generated with XmlBeans,  i see that in the properties of 
> the element “Nome” there is a difference between the Type 
> (testo70custom8e3etype) and the Type for Java Signature (testo1405c59type).
> 
> 
> 
> The three files are attached to the message.
> 
> 
> 
> Thanks for a response
> 
> 
> 
> Federico
> 
> <SubInfo.java><subinfo0d05type.xsb><xsdtest.xsd>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@xmlbeans.apache.org
> For additional commands, e-mail: user-h...@xmlbeans.apache.org

Reply via email to