users@jaxb.java.net

Re: Problem with xs:any

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Wed, 17 Jun 2009 19:55:43 +0200

Feel free to disagree with me, but I think that xs:anyType implies that the
children of this anonymous complex type should consist of an arbitrary
mixture of character data and elements.

Character data includes white space; thus you get one EOL preceding the
(single) child element <request>, and another one following it.

This would mean that 2.1.9 was in error, but 2.1.10 handles it correctly.

What about omitting <restriction>? It shouldn't be necessary unless you are
expecting character data content.

-W


On Wed, Jun 17, 2009 at 7:32 PM, Martinescu, Eduard <
Eduard.Martinescu_at_globalcrossing.com> wrote:

> The behavior of the Unmarshaller has changed between version 2.1.9 and
> 2.1.10
> with regard to how it handles XmlAny unmarshalling.
>
> For example. Given the following XSD snippet:
> <complexType>
> <complexContent>
> <restriction base="{http://www.w3.org/2001/XMLSchema}anyType<http://www.w3.org/2001/XMLSchema%7DanyType>
> ">
> <sequence>
> <any/>
> </sequence>
> <attribute name="version" use="required">
> <simpleType>
> <restriction base="{http://www.w3.org/2001/XMLSchema}string<http://www.w3.org/2001/XMLSchema%7Dstring>
> ">
> <enumeration value="1.0"/>
> </restriction>
> </simpleType>
> </attribute>
> </restriction>
> </complexContent>
> </complexType>
>
> And an appropriate definition for an element named 'request', the following
> XML
> will result in an element with an Array<Object> of 'content' and a string
> version.
>
> Given the following XML:
> <?xml version="1.0" encoding="utf-8"?>
> <ATfES version="1.0">
> <request action="AppointmentSearch">
> <appointmentRequest id="228" type="V"
> bookingIdent="6dd7f31b-38e7-46ee-97b5-c6eb547136ff" bookedAsGroup="false"
> templateId="10" hasPermission="true">
> <name>541913/7 Voice/Dedicated Voice - xxx INC</name>
> <orgClass id="3">
> <name>EON</name>
> </orgClass>
> <timeZone id="5">GMT</timeZone>
> <duration type="N">120</duration>
> <confirmationRqd>true</confirmationRqd>
> <resource id="44" booked="false">
> <name>Turnup Pool</name>
> <type>O</type>
> <state>A</state>
> <email />
> <phone />
> <timeZone id="5">GMT</timeZone>
> <attendance>R</attendance>
> <responseRequested>true</responseRequested>
> <response>N</response>
> <resource id="23" booked="true">
> <name>xxx, xxx xxx</name>
> <type>P</type>
> <state>A</state>
> <email>xxx.xxx_at_xxx.xxx</email>
> <phone />
> <timeZone id="5">GMT</timeZone>
> <attendance>R</attendance>
> <responseRequested>true</responseRequested>
> <response type="A">A</response>
> <responseDTm userId="AMS\xxx">2006-10-31T17:23:22.053</responseDTm>
> <notificationDTm
> userId="AMS\xxx">2006-10-31T17:23:22.570</notificationDTm>
> </resource>
> </resource>
> <UDF ident="1">541913/7</UDF>
> <createDTm userId="AMS\xxx" name="xxx, xxx xxx"
> email="xxx.xxx_at_xxx.xxx">2006-10-31T17:22:32.833</createDTm>
> <modifyDTm userId="AMS\xxx" name="xxx, xxx xxx"
> email="xxx.xxx_at_xxx.xxx">2006-10-31T17:23:22.040</modifyDTm>
> <appointment id="209" future="false">
> <state>A</state>
> <startDTm>2006-11-01T04:00:00</startDTm>
> <endDTm>2006-11-01T06:00:00</endDTm>
> <confirmed autoConfirmed="false">false</confirmed>
> </appointment>
> </appointmentRequest>
> <pageInfo pageNumber="1" pageSize="500" pageCount="1" rowCount="50" />
> <status type="I" ident="100000">Success.</status>
> </request>
> </ATfES>
>
>
> I get back an element with version set to "1.0", and content to be an array
> of
> objects. In version of JAXB prior to 2.1.10, the content array would
> actually
> consist of 2 elements, an 'ApointmentRequest' object, and a String "\n".
>
> With 2.1.10, the content array is now 3 elements. The first element in the
> array is now a String "\n " (newline with space), then the
> 'AppointmentRequest'
> then another String "\n"
>
> I think this is wrong...and it has definitely broken code that was relying
> upon
> the first (and should probably be only ) element in the content array to be
> the
> AppointmentRequest object.
>
> I've opened a bug report (
> https://jaxb.dev.java.net/issues/show_bug.cgi?id=646) but have had no
> responses to the bug yet, so I thought I would try here also.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>