Why does xjc choke on this RelaxNG compact schema?

213 views Asked by At

I'm trying to use xjc to generate JAXB bindings from the RelaxNG schema of the OpenGL API Registry. It's throwing a NullPointerException:

$ xjc -cp jaxb-extra-osgi-2.2.7.jar -relaxng-compact registry.rnc 
parsing a schema...
Exception in thread "main" java.lang.NullPointerException
    at com.sun.tools.internal.xjc.reader.Ring.get(Ring.java:82)
    at com.sun.tools.internal.xjc.model.CPropertyInfo.<init>(CPropertyInfo.java:110)
    at com.sun.tools.internal.xjc.model.CSingleTypePropertyInfo.<init>(CSingleTypePropertyInfo.java:57)
    at com.sun.tools.internal.xjc.model.CAttributePropertyInfo.<init>(CAttributePropertyInfo.java:58)
    at com.sun.tools.internal.xjc.reader.relaxng.ContentModelBinder.onAttribute(ContentModelBinder.java:119)
    at com.sun.tools.internal.xjc.reader.relaxng.ContentModelBinder.onAttribute(ContentModelBinder.java:55)
    at com.sun.xml.internal.rngom.digested.DAttributePattern.accept(DAttributePattern.java:58)
    at com.sun.xml.internal.rngom.digested.DPatternWalker.onContainer(DPatternWalker.java:66)
    at com.sun.xml.internal.rngom.digested.DPatternWalker.onGroup(DPatternWalker.java:87)
    at com.sun.xml.internal.rngom.digested.DPatternWalker.onGroup(DPatternWalker.java:51)
    at com.sun.xml.internal.rngom.digested.DGroupPattern.accept(DGroupPattern.java:59)
    at com.sun.tools.internal.xjc.reader.relaxng.RELAXNGCompiler.bindContentModel(RELAXNGCompiler.java:150)
    at com.sun.tools.internal.xjc.reader.relaxng.RELAXNGCompiler.compile(RELAXNGCompiler.java:143)
    at com.sun.tools.internal.xjc.reader.relaxng.RELAXNGCompiler.build(RELAXNGCompiler.java:108)
    at com.sun.tools.internal.xjc.ModelLoader.loadRELAXNG(ModelLoader.java:592)
    at com.sun.tools.internal.xjc.ModelLoader.loadRELAXNGCompact(ModelLoader.java:580)
    at com.sun.tools.internal.xjc.ModelLoader.load(ModelLoader.java:151)
    at com.sun.tools.internal.xjc.ModelLoader.load(ModelLoader.java:104)
    at com.sun.tools.internal.xjc.Driver.run(Driver.java:318)
    at com.sun.tools.internal.xjc.Driver.run(Driver.java:185)
    at com.sun.tools.internal.xjc.Driver._main(Driver.java:108)
    at com.sun.tools.internal.xjc.Driver.access$000(Driver.java:65)
    at com.sun.tools.internal.xjc.Driver$1.run(Driver.java:88)

Is something else missing from my classpath?

I know that RelaxNG support is experimental, so maybe it's just broken. As workaround, I converted the schema to XSD using Trang:

$ java -jar trang.jar -I rnc -O xsd registry.rnc registry.xsd
1

There are 1 answers

1
Michael Glavassevich On BEST ANSWER

Your stack trace seems to match a known defect (JAXB-1066) in the stand-alone version of the JAXB RI. Perhaps this is the same issue in the JDK. The bug report suggests a patch, but no one has commented on it there (yet).