Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XJC External binding file always fails

Tags:

java

jaxb

xjc

(see update below on origin of this issue)

Have any issue while trying to run xjc with any type of external binding file. Here's a copy of the binding file I'm try to use:

<jxb:bindings 
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:pd="http://chubb.com/cpi/polsvc/xmlobj"
    jxb:extensionBindingPrefixes="xjc"
    version="2.1">

    <jxb:bindings schemaLocation="your-schema.xsd">
        <jxb:bindings node="//xs:complexType[@name='AddBankVaultRplyType']">
    </jxb:bindings>
</jxb:bindings>

I know it doesn't do anything, but just trying to get a simple example to run. I'm running the following command:

xjc -extension -b src/main/resources/bindings/cXML.xjb -dtd -d tmp src/main/resources/dtds/cXML.dtd -verbose

And am getting the following errors:

parsing a schema...
[ERROR] Unsupported binding namespace "http://java.sun.com/xml/ns/jaxb". Perhaps you meant "http://java.sun.com/xml/ns/jaxb/xjc"?
  line 7 of file:/Users/nick/Development/wuxi/services/punchout/src/main/resources/bindings/cXML.xjb

[ERROR] cvc-elt.1: Cannot find the declaration of element 'jxb:bindings'.
  line 7 of file:/Users/nick/Development/wuxi/services/punchout/src/main/resources/bindings/cXML.xjb

[ERROR] Unsupported binding namespace "http://java.sun.com/xml/ns/jaxb". Perhaps you meant "http://java.sun.com/xml/ns/jaxb/xjc"?
  line 8 of file:/Users/nick/Development/wuxi/services/punchout/src/main/resources/bindings/cXML.xjb

[ERROR] Unsupported binding namespace "http://java.sun.com/xml/ns/jaxb". Perhaps you meant "http://java.sun.com/xml/ns/jaxb/xjc"?
  line 9 of file:/Users/nick/Development/wuxi/services/punchout/src/main/resources/bindings/cXML.xjb

Failed to parse a schema.

No matter what I put in the binding file for jaxb items it always files with the Perhaps you meant "http://java.sun.com/xml/ns/jaxb/xjc" type error message.

Am I missing something here? Theses seems like it should be pretty straight forward and I do not know why it's giving me issues.

XJC Version:

xjc -version
xjc 2.2.8-b130911.1802

Thanks!

UPDATE

The original purpose of the xjb file is to fix some issues with a DTD. Specifically naming conflicts such as:

[ERROR] Property "Name" is already defined. Use &lt;jaxb:property> to resolve this conflict.
like image 988
nick.stuart Avatar asked Jan 24 '26 21:01

nick.stuart


1 Answers

It's because you're compiling DTDs. That is a very different type of animal, normal bindings don't work with DTDs.

Here's a sample project which compiles DTD. The binding looks as follows:

<?xml version="1.0"?>
<xml-java-binding-schema>
    <options package="org.jvnet.hyperjaxb3.hibernate.mapping"/>
    <element name="hibernate-mapping" type="class"/>
    <element name="class" type="class" class="Clazz">
        <attribute name="subselect" property="SubselectAttribute"/>
    </element>
    <element name="typedef" type="class">
        <attribute name="class" property="Clazz"/>
    </element>
    <element name="import" type="class">
        <attribute name="class" property="Clazz"/>
    </element>
    <element name="composite-id" type="class">
        <attribute name="class" property="Clazz"/>
    </element>
    ...
</xml-java-binding-schema>
like image 143
lexicore Avatar answered Jan 26 '26 13:01

lexicore