Hi all,
I've been using the command line interface in my Ant script to run XJC
but now I'd like to start using the XJC Ant task. I'm afraid I've run
into a little problem. I didn't find anything in the archive about
this nor did ant -d help.
I used to determine whether to supply the package name by checking the
presence of any *.xjb files. If those were present I would not set the
package name, otherwise I'd set the package name (-p com.example).
I'm doing the same with the XJC Ant task but that doesn't seem to
work. If I set the package name (package="com.example") then that
works as expected. However, if I don't set the package name then the
<jaxb:package name="com.example"/> in my *.xjb file appears to be
completely ignored (I get an empty package name).
What am I doing wrong?
Cheers,
Hilco
<xjc target="${dir}" extension="true">
<binding dir="${schema.dir}">
<include name="*.xjb"/>
</binding>
<schema dir="${schema.dir}">
<include name="*.xsd"/>
</schema>
</xjc>
regions.xjb:
<jaxb:bindings
version="1.0"
xmlns:jaxb="
http://java.sun.com/xml/ns/jaxb"
xmlns:xs="
http://www.w3.org/2001/XMLSchema"
>
<jaxb:bindings schemaLocation="regions.xsd" node="//xs:schema">
<jaxb:schemaBindings>
<jaxb:package name="com.example"/>
</jaxb:schemaBindings>
</jaxb:bindings>
</jaxb:bindings>
regions.xsd:
<xs:schema
xmlns:xs="
http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
>
<xs:element name="regions">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="region"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="region">
<xs:complexType>
<xs:sequence>
<xs:element ref="label"/>
</xs:sequence>
<xs:attribute name="id" use="required" type="xs:NCName"/>
</xs:complexType>
</xs:element>
<xs:element name="label" type="xs:string"/>
</xs:schema>