I do not believe you are correct, at least with the version of
XMLBeans that I am using. I am using 2.2.0, JKD 1.4.2.

The java class I used is attached. The output is listed below:

<Root>
  <First>first string</First>
  <Second>second string</Second>
</Root>

Process finished with exit code 0

Rob




--- Ophir Bleiberg <[EMAIL PROTECTED]> wrote:

> It appears that the when creating a document through the Java API,
> the order of the elements in a sequence in the produced document is
> the order in which 'set' was called, and not the order defined in
> the schema (that is, we produce an invalid document!).  
> This seems like a reasonable bean-based approach, otherwise you
> need to know the exact schema in order to populate an XML sequence.
> Also, it means it's a real pain to modify an existing document by
> adding an optional element in the middle of a sequence.
> Surly the schema provides enough information for the engine to
> order the sequence elements regardless of the order of calling the
> 'setter' method.
> Are we doing something wrong, or is this just how XMLBeans works?
> 
> For example:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
> elementFormDefault="qualified" attributeFormDefault="unqualified">
>       <xs:element name="Root">
>               <xs:annotation>
>                       <xs:documentation>Root Element</xs:documentation>
>               </xs:annotation>
>               <xs:complexType>
>                       <xs:sequence>
>                               <xs:element name="First" type="xs:string">
>                                       <xs:annotation>
>                                               <xs:documentation>First element 
> in
> sequence</xs:documentation>
>                                       </xs:annotation>
>                               </xs:element>
>                               <xs:element name="Second" type="xs:string">
>                                       <xs:annotation>
>                                               <xs:documentation>Second 
> element in
> sequence</xs:documentation>
>                                       </xs:annotation>
>                               </xs:element>
>                       </xs:sequence>
>               </xs:complexType>
>       </xs:element>
> </xs:schema>
> 
> If we call 'setSecond' before 'setFirst' an invalid document is
> produced.
> 
>       Thanks,
>                Ophir
> 
>     "Beware of the man who works hard to learn something, 
> learns it, and finds himself no wiser than before.  He is full of 
> murderous resentment of people who are ignorant without having 
> come by their ignorance the hard way."
> 
> 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
import noNamespace.RootDocument;
import noNamespace.RootDocument.Root;
import org.apache.xmlbeans.XmlOptions;


public class test
{
    public static void main(String[] args)
    {

        RootDocument rootDocument = RootDocument.Factory.newInstance();
        Root root = rootDocument.addNewRoot();

        root.setSecond("second string");
        root.setFirst("first string");


        System.out.println(rootDocument.xmlText(new 
XmlOptions().setSavePrettyPrint()));


    }


}

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

Reply via email to