Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

xsd:complexType with extension and unordered (sometimes not all) elements

843834Jul 3 2010 — edited Jul 3 2010
Hello, I have a schema definition that I need to change.

I have the following BASE (from which I extend) elements Entity and Record Info, and I have a Quote element that extends from entity.

Some times a Quote (title, context, quoted, written) will have all its elements and some times the user will not enter the [context] for example (as the quote maybe self explanatory),

so I am in need of a definition that will allow me that.

Also I have a User entity that is working fine, but when I run the JUnit test it changes the order of userName and userPassword and what happens is that it throws an error because it is expecting the order (userName then userPassword, and not userPassword firs, and userName second) is this possible to change also?

The ideal would be a Definition that will allow me unordered elements and some of the elements can be missing also, well now that I think about it I could just put the element with an empty string, but what could I do about the order?

I need some field like id and record info, but the rest, I really don't care if title is the first element or the last.

These are my schema parts I used to have sequence but I am trying with xsd:all but it crashes:
    <xsd:complexType name="entity">
        <xsd:sequence>
            <xsd:element name="synapseId" type="xsd:string"></xsd:element>
            <xsd:element name="recordInfo" type="tns:recordInformation" xmlns:tns="http://xml.fdt.com/Schemas/Cognoscere/mainRepository"></xsd:element>
        </xsd:sequence>
        <xsd:attribute name="id" type="xsd:string"/>
        <xsd:attribute name="languageCode" type="xsd:string"/>
        <xsd:attribute name="countryCode" type="xsd:string"/>
        <xsd:attribute name="regenerateAs" type="xsd:string" use="optional"/>
    </xsd:complexType>
    <xsd:complexType name="recordInformation">
        <xsd:sequence>
            <xsd:element name="createdBy" type="xsd:string"></xsd:element>
            <xsd:element name="createdDate" type="xsd:long"></xsd:element>
            <xsd:element name="modifiedBy" type="xsd:string"></xsd:element>
            <xsd:element name="modifiedDate" type="xsd:long"></xsd:element>
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="quote">
        <xsd:complexContent>
            <xsd:extension base="tns:entity">
                <xsd:sequence>
                        <xsd:element name="title" type="xsd:string"></xsd:element>
                        <xsd:element name="context" type="xsd:string"></xsd:element>
                        <xsd:element name="preface" type="xsd:string"></xsd:element>
                        <xsd:element name="quoted" type="xsd:string"></xsd:element>
                        <xsd:element name="written" type="xsd:long"></xsd:element>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
by the way, when I tried with xsd:all minOccur etc, this is the error it threw:

s4s-elt-must-match.1: The content of 'sequence' must match (annotation?, (element | group | choice | sequence | any)*). A problem was found starting at: all. [58]

f(t)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 31 2010
Added on Jul 3 2010
1 comment
729 views