users@jaxb.java.net

Re: JAXB and xsd:any values

From: Alejandro Escalante Medina <alex.escalante_at_gmail.com>
Date: Tue, 7 Apr 2009 15:28:40 -0700

Thanks for your help, guys, I got it working!!

But now I have one more question. Here is a fragment for my xsd that I want
to customize:

<xsd:element name="Subscribe" >
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="ConsumerReference"
                     type="wsa:EndpointReferenceType"
                     minOccurs="1" maxOccurs="1" />
        <xsd:element name="Filter"
                     type="wsnt:FilterType"
                     minOccurs="0" maxOccurs="1" />

I want to customize the Java type for the Filter element of Subscribe, since
I don't like how this FilterType is generated. So I wrote the following
customization, just to test:

<jxb:bindings
node="//xsd:element[@name='Subscribe']//xsd:complexType//xsd:sequence//xsd:element[@name='Filter']">
        <jxb:javaType name="xxx.Filter"
            parseMethod="xxx.Filter..parse"
            printMethod="xxx.Filter.print" />
    </jxb:bindings>

But then xjc compiler complains like this:

 [xjc] [ERROR] (the above customization is attached to the following
location in the schema)
      [xjc] line 183 of
file:/home/alex/devel/presto/branches/FIREFLY/push/src/xsd/b-2.xsd


So, it could be this kind of customizations are not supported, but I expect
that I am doing it wroing... what do you think?

Thanks again...


Alejandro Escalante Medina
Visita mi página personal en http://weblocked.blogsome.com/


On Fri, Apr 3, 2009 at 12:29 AM, Wolfgang Laun <wolfgang.laun_at_gmail.com>wrote:

> Additional info:
>
> The prefix xjc must be bund like this:
> xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
>
> Enclose the binding in a binding/schemaLocation element:
> <jxb:bindings schemaLocation="someName.xsd">
> <jxb:bindings node="//xs:any">
> <xjc:dom/>
> </jxb:bindings>
> </jxb:bindings>
>
> -W
>
> On Fri, Apr 3, 2009 at 7:32 AM, Gary Gregory <GGregory_at_seagullsoftware.com
> > wrote:
>
>> Alejandro:
>>
>>
>>
>> You need to create an XJC binding file which should contain a fragment
>> like:
>>
>>
>>
>> <jaxb:bindings node="//xs:any">
>>
>> <xjc:dom/>
>>
>> </jaxb:bindings>
>>
>>
>>
>> Gary
>>
>>
>> ------------------------------
>>
>> *From:* Alejandro Escalante Medina [mailto:alex.escalante_at_gmail.com]
>> *Sent:* Thursday, April 02, 2009 7:40 PM
>> *To:* users_at_jaxb.dev.java.net
>> *Subject:* JAXB and xsd:any values
>>
>>
>>
>> Hello guys, I am working with jax-ws and jaxb to implement WS-I
>> Notification services.
>>
>> Everything seems to be working except for a small but important problem:
>>
>> The WS-I Notification schema specification defines the Message element as
>> being able to contain <any> content. I understand that can be any
>> well-formed xml. However, when unmarshaling inside my web service, the
>> getAny() method for the message object comes out null every time...
>>
>> Any ideas?
>>
>> The xsd for WS-I Notification is here:
>>
>> http://docs.oasis-open.org/wsn/b-2.xsd
>>
>> I am using this command line to generate types:
>>
>> xjc.sh http://docs.oasis-open.org/wsn/b-2.xsd
>>
>>
>> Thanks in advance...
>>
>> Alejandro Escalante Medina
>> Visita mi página personal en http://weblocked.blogsome.com/
>>
>
>