users@jaxb.java.net

Re: xml - java: not generating setters for <xs:element> complex types

From: Robert Lowe <robertmlowe_at_rmlowe.com>
Date: Wed, 9 Dec 2009 08:56:34 +0800

getContentItem() and getProperty() should each return a list. These lists
are modifiable, so no setters are required.


On Wed, Dec 9, 2009 at 2:43 AM, infinity2heaven
<infinity2heaven_at_gmail.com>wrote:

>
> Here's my schema:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified">
> <xs:complexType name="type-property">
> <xs:attribute name="name" type="xs:string" use="required"/>
> <xs:attribute name="value" type="xs:string" use="required"/>
> </xs:complexType>
> <xs:simpleType name="type-mime-type">
> <xs:restriction base="xs:string">
> <xs:enumeration value="text/plain"/>
> <xs:enumeration value="text/html"/>
> <xs:enumeration value="text/xml"/>
> </xs:restriction>
> </xs:simpleType>
> <xs:complexType name="type-content">
> <xs:simpleContent>
> <xs:extension base="xs:string">
> <xs:attribute name="mime-type"
> type="type-mime-type"/>
> </xs:extension>
> </xs:simpleContent>
> </xs:complexType>
> <xs:complexType name="type-content-item">
> <xs:sequence>
> <xs:element name="property" type="type-property"
> minOccurs="0"
> maxOccurs="unbounded"/>
> <xs:element name="content" type="type-content"/>
> </xs:sequence>
> <xs:attribute name="id" type="xs:string" use="required"/>
> <!-- Shared content or "widget" id. -->
> </xs:complexType>
>
> <xs:element name="page">
> <xs:complexType>
> <xs:sequence>
> <xs:element name="property"
> type="type-property" minOccurs="0"
> maxOccurs="unbounded"/>
> <xs:element name="content-item"
> type="type-content-item" minOccurs="0"
> maxOccurs="unbounded"/>
> </xs:sequence>
> <xs:attribute name="id" type="xs:string"
> use="required"/>
> <!-- Shared page id. -->
> </xs:complexType>
> </xs:element>
> </xs:schema>
>
> When I generate jaxb representations, the java classes do not have a
> setters
> generated for any xs:element type. In the example above, I get
>
> class Page {
> id
> contentItem
> Property
>
> getId()
> setId()
> getContentItem()
> getProperty()
>
> }
>
> Is there anything I need to do to generate setters by default?
>
> Also, how do I change the default name for a collection to end with an "s".
> In the example above, I'd like to have contentItems instead of contentItem.
> --
> View this message in context:
> http://old.nabble.com/xml---java%3A-not-generating-setters-for-%3Cxs%3Aelement%3E-complex-types-tp26698648p26698648.html
> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>


-- 
Best regards,
Robert Lowe
http://rmlowe.com/