Paul Michael Reilly wrote:
> Joe Fialli wrote:
>
>> Paul Michael Reilly wrote:
>>
>>> Joe Fialli wrote:
>>>
>>>> Paul Michael Reilly wrote:
>>>>
>>>>> In XML-RPC there is a nasty problem in the <value> element. It can
>>>>> have
>>>>> defaulted string data, i.e. both
>>>>>
>>>>> <value>This is the default string value</value>
>>>>>
>>>>> and
>>>>>
>>>>> <value><string>This is non-defaulted string value.</string></value>
>>>>>
>>>>> can be valid input.
>>>>>
>>>>> I have successfully modeled this (no validation errors) using the
>>>>> schema:
>>>>>
>>>>> <xsd:complexType name="ValueType" mixed="true">
>>>>> <xsd:choice>
>>>>> ...
>>>>> <xsd:element name="int" type="xsd:int" nillable="true"
>>>>> minOccurs="0" maxOccurs="1"/>
>>>>> <xsd:element name="string" type="ASCIIString" minOccurs="0"
>>>>> maxOccurs="1"/>
>>>>> ....
>>>>> </xsd:choice>
>>>>> </xsd:choice>
>>>>>
>>>>> but I have not figured out how to access the default text using JAXB.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Could you illustrate how one defaults text? The above schema does
>>>> not contain the defaulted text in it.
>>>
>>>
>>>
>>>
>>> Normally one expects an input stream of the form:
>>>
>>> ...<value><string>Text text text</string></value>...
>>>
>>> but it is also valid to receive:
>>>
>>> ...<value>Text text text</value>...
>>>
>>> That clear?
>>
>>
>>
>> Your previous usage of defaulted text mislead me. I believe you are
>> just asking how JAXB binds mixed content and provides a user
>> access the text information of the mixed content.
>>
>> JAXB 1.0 Specification describes the binding for mixed mode in
>> Section 5.9.4
>> "Bind mixed content". You can download the specification from
>> http://java.sun.com/xml/downloads/jaxb.html.
>>
>> It has an example that illustrates that mixed content is bound to a
>> Collection property
>> represented by a method called getContent that returns a List.
>> The list is composed of elements and java.lang.String instances. The
>> text information from XML document is represented by the
>> java.lang.String instances.
>> By mapping to a list, the binding is able to preserve the order
>> relationship
>> between the text and elements of the content model. You can download
>> the specification
>> from http://java.sun.com/xml/downloads/jaxb.html.
>>
>> -Joe
>
>
> Interesting, the plot thickens. I do see a getContent() method
> generated for ValueType that is of type Object rather than List. This
> is independent of whether I use the mixed attribute or not. I do use
> the following local bindings:
> <jxb:bindings version="1.0"
> xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
> <jxb:bindings schemaLocation="xml-rpc.xsd" node="/xsd:schema">
>
> <!-- Illustrate binding model group to content interfaces. -->
> <jxb:globalBindings bindingStyle="modelGroupBinding"/>
> <jxb:schemaBindings>
> <jxb:package name="com.starbak.manage.rpc.xmlrpc.beans"/>
> </jxb:schemaBindings>
> </jxb:bindings>
>
> </jxb:bindings>
>
> in order to get the "isSet...()" methods on my choices. Could this be
> interfering with the generation of the getContent() method that
> returns the List? If so, I think this may be a bug.
I agree that it is a bug. Handling mixed content is handled as an
exception case in the
both binding styles.
Here is binding rule from the JAXB 1.0 specification
Section 6.12.11 Model Group binding algorithm (one you are using)
The following rules describe how to bind a content model to its Java
representation when customizations specify that a content model or nested
model group be bound using the model group binding style:
1. When {content type} is mixed - Bind the entire content model to a
general content property
with the content-property name "content". See Section 6.12.3,“General
content property” for more details.
6.12.7 Content Model Default Binding
The following rules define element binding style for a complex type
definition’s
content model.
1. If {content type} is mixed, bind the entire content model to a
general content
property with the content-property name “content”. See
Section 6.12.4, “Bind mixed content” for more details.
-Joe
>
> -pmr
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net