users@jaxb.java.net

Re: No concrete java class generated for a global element that references a global type

From: Ed Mooney <Ed.Mooney_at_Sun.COM>
Date: Mon, 30 Jan 2006 14:47:44 -0500

Hi Dmitri,

It occurs to me @generateElementClass is a better way to do what you want:

     <xsd:schema
       targetNamespace="urn:missingRootElement"
       xmlns="urn:missingRootElement"
       xmlns:xsd="http://www.w3.org/2001/XMLSchema"
       elementFormDefault="qualified"
       xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
       jaxb:version="2.0">

       <xsd:annotation>
         <xsd:appinfo>
           <jaxb:globalBindings generateElementClass="true"/>
         </xsd:appinfo>
       </xsd:annotation>
       <xsd:complexType name="MyComplexType">
         <xsd:sequence>
           <xsd:element name="InnerString" type="xsd:string"
maxOccurs="unbounded" />
         </xsd:sequence>
       </xsd:complexType>

       <xsd:element name="MyElement" type="MyComplexType" />

     </xsd:schema>

Regards,

   -- Ed

Dmitri Colebatch wrote:
> Hi all,
>
> I would swear that this has been asked in one way or another but I
> must be searching for the wrong things. I have a schema like this:
>
> <xsd:schema
> targetNamespace="urn:missingRootElement"
> xmlns="urn:missingRootElement"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> elementFormDefault="qualified">
>
> <xsd:complexType name="MyComplexType">
> <xsd:sequence>
> <xsd:element name="InnerString" type="xsd:string" maxOccurs="unbounded" />
> </xsd:sequence>
> </xsd:complexType>
>
> <xsd:element name="MyElement" type="MyComplexType" />
>
> </xsd:schema>
>
> and when I run xjc over it all I get is:
>
> parsing a schema...
> compiling a schema...
> missingrootelement\MyComplexType.java
> missingrootelement\ObjectFactory.java
> missingrootelement\package-info.java
>
> ie - there's no MyElement class.
>
> I suppose I'm asking two questions:
>
> 1. Is it possible to generate a MyElement class in the above example?
> 2. What is the rationale behind not generating a MyElement class by default?
>
> cheers
> dim
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>