users@jaxb.java.net

Re: Any to Anies

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Wed, 11 Mar 2009 13:30:14 +0100

This compiles OK if the agw namespace URL is corrected (www.mycomp.com in
all places)
and the missing '>' is added.

==========
public class Body {

    @XmlElement(name = "any-xing", namespace = "", required = true)
    protected AnyContent anyXing;
=========

I've been using xjc from jdk1.6.0_04.

-W


On Wed, Mar 11, 2009 at 12:23 PM, <christer.larsson_at_seb.se> wrote:

> Hi.
>
> Been using the <xjc:simple/> tag to generate my classes and am experiencing
> strange behaviour
> not sure if it is because of this tag or some error in my schemata
>
> I have the following schemata
>
> base.xsd
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <xs:schema targetNamespace="http://www.mycomp.com/ns/tf/agw"
> attributeFormDefault="unqualified" elementFormDefault="unqualified"
> xmlns:xs="http://www.w3.org/2001/XMLSchema" >
>
> <!-- *** Document content *** -->
> <xs:element type="agw:Module" name="module"/>
> <xs:element type="xs:string" name="origin-addr"/>
> <xs:element type="xs:string" name="user"/>
>
> <!-- *** Types *** -->
> <xs:simpleType name="Module">
> <xs:restriction base="xs:string">
> <xs:enumeration value="dymo"/>
> </xs:restriction>
> </xs:simpleType>
>
> <xs:element name="body">
> <xs:complexType>
> <xs:sequence>
> <xs:element type="agw:AnyContent" name="any-xing"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> <xs:complexType name="AnyContent">
> <xs:sequence>
> <xs:any minOccurs="1" maxOccurs="unbounded"/>
> </xs:sequence>
> </xs:complexType>
> </xs:schema>
>
> request.xsd
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <xs:schema targetNamespace="http://www.pantor.com/ns/tf/agw"
> attributeFormDefault="unqualified" elementFormDefault="unqualified"
> xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:agw="http://www.mycomp
> .com/ns/tf/agw"
>
> <!-- *** Import schemas *** -->
> <xs:include schemaLocation="base.xsd"/>
>
> <!-- *** Document content *** -->
> <xs:element name="request">
> <xs:complexType>
> <xs:all>
> <xs:element ref="agw:module"/>
> <xs:element ref="agw:origin-addr"/>
> <xs:element ref="agw:user"/>
> <xs:element ref="agw:body"/>
> </xs:all>
> </xs:complexType>
> </xs:element>
> </xs:schema>
>
> reply.xsd
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <xs:schema attributeFormDefault="unqualified" elementFormDefault=
> "unqualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:agw="
> http://www.pantor.com/ns/tf/agw">
>
> <!-- *** Import schemas *** -->
> <xs:import schemaLocation="base.xsd" namespace="http://www.mycomp
> .com/ns/tf/agw"/>
>
> <!-- *** Document content *** -->
> <xs:element type="AnyPotentiallyEmptyContent" name="reply"/>
>
> <xs:element type="agw:AnyContent" name="error"/>
>
> <!-- *** Types *** -->
> <xs:complexType name="AnyPotentiallyEmptyContent">
> <xs:sequence>
> <xs:any minOccurs="0" maxOccurs="unbounded"/>
> </xs:sequence>
> </xs:complexType>
> </xs:schema>
>
> The problem I am having is that the Body element (in base.xsd) is being
> given the child element Error instead of
> child element Any-xing and I don't understand how this could happen. So the
> corresponding generated Body class looks like this:
>
> <snip>
>
> @XmlAccessorType(XmlAccessType.*FIELD*)
> @XmlType(name = "", propOrder = {
> "anyXing"
> })
> @XmlRootElement(name = "body")
> *public** class* Body {
>
> @XmlElement(name = "any-xing", namespace = "", required =* true*)
> * protected* Error anyXing;
>
> /**
> * Gets the value of the anyXing property.
> *
> ** @return*
> * possible object is
> * {_at_link Error }
> *
> */
> * public* Error getAnyXing() {
> * return* anyXing;
> }
> </snip>
>
> /Christer
>