Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 649683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:58:15+00:00 2026-05-13T21:58:15+00:00

I have this schema: <xs:complexType name=foo> <xs:sequence> <xs:element name=oneBar type=xs:string minOccurs=0/> <xs:element name=twoBar type=xs:string

  • 0

I have this schema:

<xs:complexType name="foo">
  <xs:sequence>
    <xs:element name="oneBar" type="xs:string" minOccurs="0"/>
    <xs:element name="twoBar" type="xs:string" minOccurs="0"/>
  </xs:sequence>
</xs:complexType>

When I try to unmarshal this

<foo>
  <oneBar>1</oneBar>
  <twoBar>2</twoBar>
</foo>

it works
but when I try to unmarshal this xml:

<foo>
   <twoBar>2</twoBar>
   <oneBar>1</oneBar>
</foo>

I get an excelption because it cares about the order
If I try to unmarshal the same xml without using a schema it works in both cases
Any ideas?

As Strawberry pointed out if you replace the xs:sequence with sc:any order wont matter, does any of you know what annotation I need to put in my class so it will generate the xs:any schmea

Found solution by creating the class from the xs:any schema
You just need to annotate your class with XmlType and set the prop order to be nothing, see:

@XmlRootElement
@XmlType(name="foo",propOrder={})
public class Foo {
    @XmlElement
    public String oneBar; 
    @XmlElement
    public String twoBar;
} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:58:15+00:00Added an answer on May 13, 2026 at 9:58 pm

    Sequence requires elements be in order e.g. from w3schools page:-

    The indicator specifies
    that the child elements must appear in
    a specific order:

    When unmarshalling without a schema you are effectively not validating the XML.

    If you want your schema to NOT require a specific ordering then the following should do that:-

    <xs:complexType name="foo">
      <xs:all>
        <xs:element name="oneBar" type="xs:string" minOccurs="0"/>
        <xs:element name="twoBar" type="xs:string" minOccurs="0"/>
      </xs:all>
    </xs:complexType>
    

    Approaching it from the Java annotation point of view. If I have a Class called Test with two string fields test1 and test2, the annotations would be:-

    The ordered case e.g. using <sequence>

    @XmlType(name="",propOrder={"test1","test2"})
    @XmlRootElement(name="test")
    public class Test
    {
       @XmlElement(required=true)
       private String test1;
       @XmlElement(required=true)
       private String test2;
    }
    

    The un-ordered case e.g. using <all>

    @XmlType(name="",propOrder={})
    @XmlRootElement(name="test")
    public class Test
    {
       @XmlElement(required=true)
       private String test1;
       @XmlElement(required=true)
       private String test2;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML schema: <xsd:element name=Person> <xsd:complexType> <xsd:sequence> <xsd:element name=name type=xsd:string /> <xsd:element
Given this XML Schema snippet: <xs:element name=data> <xs:complexType> <xs:sequence> <xs:element name=param type=param minOccurs=0 maxOccurs=unbounded
Suppose I have this (outrageously) simplified XML schema: <xsd:complexType name=Person> <xsd:sequence> <xsd:element ref=FirstName/> <xsd:element
I have a schema fragment that looks like <xs:element name=dataValue> <xs:complexType> <xs:sequence> <xs:element name=value
I have an xsd (for basecamp xml) that contains <xsd:complexType name=ProjectType> <xsd:sequence> <xsd:element name=announcement
I have a table which have schema like this id name 1 jack 2
We have this XML schema: <xs:schema attributeFormDefault=unqualified elementFormDefault=qualified xmlns:xs=http://www.w3.org/2001/XMLSchema> <xs:element name=Log> <xs:complexType> <xs:sequence minOccurs=0
I have this schema: <?xml version=1.0 encoding=UTF-8?> <xs:schema xmlns:xs=http://www.w3.org/2001/XMLSchema> <xs:simpleType name=errorType> <xs:restriction base=xs:decimal> <xs:totalDigits
I have this schema which I need to match 2 rows from user_data :
I have this schema: There is a table for persons. Each person has one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.