users@jaxb.java.net

Re: serializeAttributes - differing order

From: Joe Fialli <joseph.fialli_at_sun.com>
Date: Thu, 30 Jan 2003 08:35:47 -0500

Steve Hind wrote:
> Hi All,
>
> This may be an xml schema issue? I'm uncertain.
> When we generate an xml file via JAXB the order of our attributes differ
> from the sequence in the schema.
> When looking at the implemented (generated JAXB) code. The order of the
> elements are same as in the schema, but the order of the attributes are not.
> I realise that this is not a functional requirement but it would be nice to
> have the attributes in a logical sequence. Can we enforce this?
>
> Is this something we are missing in our schema setup?

The order of attributes is not semantically important as far as
basic XML Schema is concerned.Canonicalization for encryption/digital
signatures does impose an ordering (I doubt the order within the document
though) on attributes. Look through the archives, I know that I have addressed
this question on the list in the past.

Rather than take an overhead hit to preserve
ordering that is not semantically meaningful, the JAXB reference
implementation does not attempt to remember the attribute order
from an XML document. The JAXB specification does not require that
an implementation forget the ordering, it just does not place the
requirement to retain the ordering that is not semantically meaningful
as far as the XML Schema specification is concerned.

-Joe Fialli, Sun Microsystems

>
> TIA, sorry if OT.
> Steve
>
> The element in question is...
> <xs:element name="web-page">
> <xs:complexType>
> <xs:sequence>
> <xs:element ref="presentation"/>
> <xs:element ref="content" minOccurs="0"/>
> <xs:element ref="input-parameters"
> minOccurs="0"/>
> <xs:element ref="event-handling"
> minOccurs="0"/>
> <xs:element ref="action-processes"
> minOccurs="0"/>
> </xs:sequence>
> <xs:attribute name="name" type="xs:string"
> use="required"/>
> <xs:attribute name="screen-type" use="required">
> <xs:simpleType>
> <xs:restriction base="xs:string">
> <xs:enumeration
> value="xr_st_single_record"/>
> <xs:enumeration
> value="xr_st_multi_record"/>
> <xs:enumeration
> value="xr_st_utility"/>
> </xs:restriction>
> </xs:simpleType>
> </xs:attribute>
> <xs:attribute name="web-page-bean-class"
> type="xs:string" use="optional"/>
> </xs:complexType>
> </xs:element>
>
>
> **********************************************************************
> Privileged, confidential and/or copyright information may be contained
> in this e-mail. This e-mail is for the use only of the intended
> addressee. If you are not the intended addressee, or the person
> responsible for delivering it to the intended addressee, you may not
> copy, forward, disclose or otherwise use it or any part of it in any
> way whatsoever. To do so is prohibited and may be unlawful.
>
> If you receive this e-mail by mistake please advise the sender
> immediately by using the reply facility in your e-mail software.
>
> Orygen (UK) Limited may monitor the content of e-mails sent and
> received via its network for the purposes of ensuring compliance with
> its policies and procedures.
>
> This message is subject to and does not create or vary any contractual
> relationship between Orygen (UK) Limited and you
> **********************************************************************


--