Skip to main content

2.0-RC1 Boolean problem

5 replies [Last post]
Joined: 2006-03-30

i'm producing bindings for the OGC schemas using the 2.0 RC, but i'm having problems with the isMaximal attribute.
in the TopoComplexType from gml/3.1.1/topology.xsd, we have this definition:

This type represents a TP_Complex capable of holding topological primitives.

(the declared namespaces from the schema header are:

i've attempted a few things in the xjb file:

in order to use the boolean primitive


in order to not have get/setIsMaximal

when i produce bindings, i get these methods in
public boolean isMaximal() {
if (maximal == null) {
return new Adapter2().unmarshal("false");
} else {
return maximal;
public void setMaximal(Boolean value) {
this.maximal = value;

unfortunately, maximal is declared like this:
@XmlAttribute(name = "isMaximal")
@XmlJavaTypeAdapter(Adapter2 .class)
protected Boolean maximal;

and appears thusly:
package org.w3._2001.xmlschema;
import javax.xml.bind.annotation.adapters.XmlAdapter;
public class Adapter2 extends XmlAdapter {
public Boolean unmarshal(String value) {
return (javax.xml.bind.DatatypeConverter.parseBoolean(value));
public String marshal(Boolean value) {
return (javax.xml.bind.DatatypeConverter.printBoolean(value));

when i compile, it complains about incompatible types:
\gml3_1_1\ incompatible types
[javac] found : net.opengis.gml3_1_1.Boolean
[javac] required: boolean
[javac] return isMaximal;
[javac] ^

where am i missing how to make it output the boolean primitive?
i thought that the globalBinding javaType would take care of that?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2006-03-30

ack, now that you mention it, the gml/3.1.1/base/valueObjects.xsd *does* have it's own "Boolean" element (with type="boolean"). this element is referenced in other element definitions in the same schema. but there is no produced java file for i still don't see where net.opengis.gml3_1_1.Boolean is coming from...

bah, eliminating that "Boolean" element still didn't help (i changed all refs to it to element name="Boolean" type="boolean", but with the isMaximal default="false" back in place, i get the same weird isMaximal result. are there oddities about default="..." handling? isn't "false" the default anyway (without declaring it)?

bah2, i tried to do the xjb mapping for the Boolean element to GMLBoolean, but no luck there either.

lemme put a zip together and i'll send it to you

Joined: 2006-03-30

the xmlns for the schema is "". i thought that would be the default namespace, so the type="boolean" should have been equivalent to type="xsd:boolean". if, perhaps, jaxb is looking for xsd:boolean instead of boolean, perhaps that's my issue?...well, no, i just looked through some of the other schemas i'm binding at the same time, and some with xsd:boolean have the same issue with their generated code.

i am not consciously trying to use an just seems to happen (sometimes i get 3, sometimes i get 4...i haven't dug into why).

my main issue is how can i use the xjb file to direct 2.0-RC1 to use boolean instead of Boolean? i can't find any good information on using jaxb:javaType in 2.0 (i can't find any information regarding anything advanced with xjb files at all).

i am attempting to bind the OGC schemas from i am doing this in two batches, because although the OGC produces excellent GIS web service specifications, they don't always make the best schemas. so during the past year, i refactored a group of OGC schemas (filter 1.0.0, gml 2.1.2, sld 1.0.20, wfs 1.0.0, wms 1.3.0) so that they would produce good bindings using JAXB 1.0. i used an external xjb file to handle things like _NamesWithUnderscoresFirst and to associate some schema number types with java primitives rather than BigInteger. i succeeded in this, and life was grand.

now, i need to produce bindings for another set of schemas (csw 2.0.1, filter 1.1.0, gml 3.1.1, ows 1.0.0, xlink 1.0.0). this *immediately* became an issue because the version numbers didn't carve out new namespaces, they reused the old ones, so i can't bind gml 2.1.2 and gml 3.1.1 at the same time. instead, i have a precompile ant task that calls the xjc task twice: once on the first batch of schemas using JAXB1.0, and then on the second batch of schemas using JAXB 2.0. i continue to use JAXB1.0 on the first set because the JAXB2.0 generated code broke the filtering code completely (JAXB2.0 left some contents as String, rather than the mixed List of Strings and binding objects). i pushed forward with JAXB2.0 on the new set of schemas (including the currently offending schema in gml 3.1.1) because i was getting AnyType collisions between the two binding-compiler calls.

so great, now i do one and then the other, the packages are all unique thanks to the xjb files, the JAXB1.0 javaType mappings still work, but the JAXB2.0 javaType mappings don't work at all. and worse, it's doing funky things to the booleans.

the compile error is *extremely* confusing. when the file is viewed in Eclipse, it looks like a java.lang.Boolean (i can ctrl-hover and follow it to java.lang.Boolean). nor can i find any declaration of net.opengis.gml3_1_1.Boolean. i must admit, my knowledge of annotations is nonexistant, so i'm not able to ascertain the significance of the annotations on the protected Boolean maximal.

as mentioned, the schemas are available at the minimal set to work with to see this error should be filter 1.1.0, gml 3.1.1, and xlink 1.0.0. i have an extensive xjb file for dealing with things in the gml 3.1.1 schemas, pasted in below (sorry, i don't know how to format code in this forum...drop it in xmlspy to beautify it). as you can see, i do have some globalBindings that don't seem to have any affect on the binding-compile. you'll also notice that i adhere to bindingschema_1_0...cos it doesn't validate against bindingschema_2_0 (i noticed, too, that the online bindingschema_2_0 didn't match the bindings.xsd in 2.0-RC1)


Joined: 2003-06-09

In one of the error messages, I saw [b]net.opengis.gml3_1_1.Boolean[/b], so I thought you had your own boolean type (besides the obvious xs:boolean.) Are you sure you don't have any such definition?

If so, are you suspecting that XJC generated net.opengis.gml3_1_1.Boolean out of xs:boolean?

> my main issue is how can i use the xjb file to direct
> 2.0-RC1 to use boolean instead of Boolean? i can't find
> any good information on using jaxb:javaType in 2.0 (i
> can't find any information regarding anything advanced
> with xjb files at all).

Given the definition of maximal:


XJC should give you a boolean (not Boolean) property by default (you are using to rename it, and that's fine --- you should still get a boolean field.)

I really think the main issue is that GML schema has its own boolean type, and that triggers a bug in the JAXB code generator, which causes it to generate uncompilable source code. As you see, you are getting boolean as the method signature right there! (That and the lack of good documentation --- it's supposed to be on its way)

To format the code in this forum, use [ c o d e ] and [ / c o d e ] (without any space in between) I'd really appreciate if you could send me a zip file or something to reproduce the problem. That would really let me fix this issue quickly.

Joined: 2006-03-30

well, i made it work by whacking the default="false" for the isMaximal attribute, but it's still a java.lang.Boolean instead of a boolean primitive. anyone know if 2.0-RC1 has issues with primitives?

Joined: 2003-06-09

This error is confusing. Looks like your schema has its own "boolean" type that collides with java.lang.Boolean?

Why are you trying an adapter? Does that relate to the default value?

What is the issue? Is it that you are trying to work around the two Boolean collision by using adapters or some other means? If so, we should just fix XJC so that it can generate the correctly (by fully qualifying it) --- we do have a test case like that internally, but maybe this has some new aspect to it.

Is this a schema I can download and try it for by myself?