xml-xmlbeans-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Vasilik" <eric...@bea.com>
Subject RE: order of elements in a sequence
Date Tue, 06 Jul 2004 01:24:06 GMT
The order of the elements delivered to the sax handler will be the order
that they exist in the store.  Based on your code, the elements must be
going into the store in the order that the saver suggests they are.  

The schema has no effect on the Xml infoset as it is read in.  Take a
closer look at the order of the sax events you are generating.

- Eric

-----Original Message-----
From: Nikhil Dinesh [mailto:nikhild@seas.upenn.edu] 
Sent: Monday, July 05, 2004 2:44 PM
To: xmlbeans-user@xml.apache.org
Subject: RE: order of elements in a sequence

Nothing at all. This was just a test case where I read it in and write
it
out.

The code looks like the following:

XmlSaxHandler viewDestHandler =
XmlBeans.getContextTypeLoader().newXmlSaxHandler(ViewChartDocument.type,
null);

//This is a saxHandler which passes through events to another saxHandler
//applying some transformations (which do not involve changing the
order).
//Since the document starts of in a dtd this handles the changing of
//namespaces etc
MySaxHandler saxHandler = new
MySaxHandler(viewDestHandler.getContentHandler(),
viewDestHandler.getLexicalHandler());

....(code that does the reading)

ViewChartDocument doc =
(ViewChartDocument)(viewDestHandler.getObject());
doc.save(System.err);


On Mon, 5 Jul 2004, Eric Vasilik wrote:

> What are you doing to the instance between the time you read it in and
> save it out?  XmlBeans preserves the XML Infoset while providing you
> access to the strongly typed data.
>
> - Eric
>
> -----Original Message-----
> From: Nikhil Dinesh [mailto:nikhild@seas.upenn.edu]
> Sent: Monday, July 05, 2004 2:12 PM
> To: xmlbeans-user@xml.apache.org
> Subject: order of elements in a sequence
>
> Hi,
>
> Im having trouble getting XmlBeans to save the elements of a sequence
in
> order. I have a complex type defined similar to the following:
>
> <complexType name="fooId>
>   <attribute name="id" type="ID" />
> </complexType>
>
> <complexType name="fooId2">
>   <complexContent>
>     <extension base="fooId">
>       <attribute name="type" type="string" />
>     </extension>
>   </complexContent>
> </complexType>
>
> <complextType name="fooInstance">
>   <complexContent>
>     <extension base="fooId">
>       <sequence>
>         <element name="a" type="fooId" minOccurs="0"
> maxOccurs="unbounded"/>
>         <element name="b" type="fooId2" minOccurs="0"
> maxOccurs="unbounded"/>
>       </sequence>
>     </extension>
>   </complexContent>
> </complexType>
>
> A file is read in such that all the "<a>'s" occur before the "<b>'s".
> This
> is done by messaging the contentHandler. But when I try to save it,
the
> a's and b's are interspersed.
>
> Ive tried setting minOccurs=maxOccurs=1 on the sequence element.
Doesnt
> that guarantee that it will be split into atmost one subsequence as
per
> the W3c recommendation? But that doesnt work either.
>
> The sequence order is needed because the persistent form of the XML
> needs
> to be compatible with a DTD. I could of course walk over the tree, but
> that seems like a very bad solution.
>
> Any suggestions?
>
> Thanks,
> Nikhil
>
>
>
> -
---------------------------------------------------------------------
> To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
> Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/
>
>
> -
---------------------------------------------------------------------
> To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
> Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/
>
>

- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/


Mime
View raw message