Java classes generation problem with JAXB

View: New views
3 Messages — Rating Filter:   Alert me  

Java classes generation problem with JAXB

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am trying to generate Java classes from an xsd file using JAXB and have two questions.

1) I have this xsd definition where I define a complexType that contains a list.

<xs:complexType name="person">
  <xs:sequence>
    <xs:element name="full_name" type="xs:string"/>
    <xs:element name="child_name" type="xs:string" maxOccurs="unbounded"/>
  </xs:sequence>
</xs:complexType>
 
The question is why the setter is not being generated ?
In the example, the generated Java class doesn't contain the setter method for child_name list.

2) I have this other complexType definition.

  <xs:complexType name="Name">
          <xs:sequence maxOccurs="unbounded">
            <xs:element name="First" type="xs:string"/>
            <xs:element name="Middle" type="xs:string" minOccurs="0" />
            <xs:element name="Last" type="xs:string"/>
            <xs:element name="Initials" minOccurs="0" type="xs:string"/>
          </xs:sequence>
    </xs:complexType>
The generated Java class has only one attribute named: firstAndMiddleAndLast.
Is there any way or configuration that I can do to set another name for this attribute without using the binding .xjb file?

thanks a lot!!
[Message sent by forum member 'pferreyra' (pferreyra)]

http://forums.java.net/jive/thread.jspa?messageID=354529

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Java classes generation problem with JAXB

by Daniel Gorodowienko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

metro@... wrote:

> I am trying to generate Java classes from an xsd file using JAXB and have two questions.
>
> 1) I have this xsd definition where I define a complexType that contains a list.
>
> <xs:complexType name="person">
>   <xs:sequence>
>     <xs:element name="full_name" type="xs:string"/>
>     <xs:element name="child_name" type="xs:string" maxOccurs="unbounded"/>
>   </xs:sequence>
> </xs:complexType>
>  
> The question is why the setter is not being generated ?
> In the example, the generated Java class doesn't contain the setter method for child_name list.

If there is list created in class code, then getter is enough. When you
get list, it's created, and then you can add elements to it.

>
> 2) I have this other complexType definition.
>
>   <xs:complexType name="Name">
>           <xs:sequence maxOccurs="unbounded">
>             <xs:element name="First" type="xs:string"/>
>             <xs:element name="Middle" type="xs:string" minOccurs="0" />
>             <xs:element name="Last" type="xs:string"/>
>             <xs:element name="Initials" minOccurs="0" type="xs:string"/>
>           </xs:sequence>
>     </xs:complexType>
> The generated Java class has only one attribute named: firstAndMiddleAndLast.
> Is there any way or configuration that I can do to set another name for this attribute without using the binding .xjb file?
>
> thanks a lot!!
> [Message sent by forum member 'pferreyra' (pferreyra)]
>
> http://forums.java.net/jive/thread.jspa?messageID=354529
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...


Re: Java classes generation problem with JAXB

by metro-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

is there any reason why is implemented like this?

>If there is list created in class code, then getter is enough. When you
>get list, it's created, and then you can add elements to it.
[Message sent by forum member 'pferreyra' (pferreyra)]

http://forums.java.net/jive/thread.jspa?messageID=355433

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...