> -----Original Message-----
> From: KARR, DAVID (ATTSI)
> Sent: Friday, October 15, 2010 8:34 AM
> To: users_at_jaxb.dev.java.net
> Subject: bindings to convert common container pattern from schema to
> java
>
> It seems to me that one of the most common patterns for modifying the
> mapping from schema to Java is seen in this common container pattern:
>
> XML:
> <services>
> <service>...</service>
> <service>...</service>
> </services>
>
> Java:
> private List<Service> services;
> public List<Service> getServices() { ... }
> public void setServices(List<Service> services) { ... }
>
> Both of these are how I would want the pattern rendered. However, no
> matter if you're building schema-first or Java-first, the other side
> won't work out that way unless you modify the bindings.
>
> When I've built this Java-first, I would add the following before the
> instance variable:
>
> @XmlElementWrapper(name = "services")
> @XmlElement(name = "service")
>
> This produces the schema structure that I want.
>
> Now, I have to go the other direction. I have a hand-coded schema with
> the correct structure, and I have to build the "jxb:bindings"
structure
> to result in the correct structure in the Java code.
>
> I've found several occurrences of the "documentation" for
> "jxb:bindings", but all of them seem to cover the same similar
examples
> and not cover an example like this. Can someone explain in detail how
> I
> would do this? Bonus points for pointing me to documentation that
> actually talks about examples like this.
For a little more background, I currently get an instance variable in
the container corresponding to the "services" element like this:
@XmlElement(required = true)
protected ServiceCallResults.Services services;
I think what I really want to see is this:
@XmlElement(required = true)
protected List<Service> services;
After realizing this, I thought perhaps that just something like this
would do it:
<jxb:bindings node=".//xsd:element[name='services']">
<jxb:javaType name="List<Service>"/>
</jxb:bindings>
Unfortunately, xjc barfs on this, saying I couldn't have "<" characters.
So I then tried url-encoding those characters, and now it just says:
[xjc] [ERROR] compiler was unable to honor this javaType customization.
It is attached to a wrong place, or its inconsistent with other
bindings.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net