javaee / jaxb-v2

Other
211 stars 100 forks source link

SCD bindings do not support custom/vendor customization elements #1047

Open glassfishrobot opened 10 years ago

glassfishrobot commented 10 years ago

I wrote a number of XJC plugins, some of these plugins can be customized via binding files.

For instance, I can do the following:

<jaxb:bindings version="1.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"   xmlns:xs="http://www.w3.org/2001/XMLSchema"     xmlns:jsonix="http://jsonix.highsource.org/customizations"  jaxb:extensionBindingPrefixes="jsonix">

    <jaxb:bindings schemaLocation="w3c/1999/xlink.xsd" node="/xs:schema">
        <jsonix:packageMapping packageName="org.hisrc.w3c.xlink.v_1_0" spaceName="XLink_1_0"/>
    </jaxb:bindings>
</jaxb:bindings>

If my Jsonix plugin is activated, XJC will know that jsonix:packageMapping is a customization element for Jsonix (plugin API allows saying what your customization namespace URI is and which local names you expect).

SCD seems to be a more advanced way to address schema elements. I.e.

<jaxb:bindings scd="x-schema::xlink" xmlns:xlink="http://www.w3.org/1999/xlink" ... />

addresses the XLink schema logically via namespace URI. Forget the files, this is perfect. Much more versatile than schemaLocation and node. I guess episodes would not work without SCD in first place. For my scenarios it would for instance help with #1047.

My problem is that SCD does not allow custom elements. So this:

<jaxb:bindings version="1.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"   xmlns:xs="http://www.w3.org/2001/XMLSchema"     xmlns:jsonix="http://jsonix.highsource.org/customizations"  jaxb:extensionBindingPrefixes="jsonix">

    <jaxb:bindings scd="x-schema::xlink" xmlns:xlink="http://www.w3.org/1999/xlink">        <jsonix:packageMapping packageName="org.hisrc.w3c.xlink.v_1_0" spaceName="XLink_1_0"/>
    </jaxb:bindings>
</jaxb:bindings>

I get the following error:

[ERROR] Error while parsing schema(s).Location [ file:/C:/Projects/workspaces/ogc-ng/w3c-schemas/xlink/1999/src/main/resources/xlink-v_1_0.jsonix.xjb{8,89}].
org.xml.sax.SAXParseException; systemId: file:/C:/Projects/workspaces/ogc-ng/w3c-schemas/xlink/1999/src/main/resources/xlink-v_1_0.jsonix.xjb; lineNumber: 8; columnNumber: 89; cvc-elt.1: Cannot find the declaration of element 'jsonix:packageMapping'.

Clearly, SCD does not process custom configuration elements whereas schemaLocation plus node do process.

glassfishrobot commented 10 years ago

Reported by lexi

glassfishrobot commented 10 years ago

Was assigned to yaroska

glassfishrobot commented 7 years ago

This issue was imported from java.net JIRA JAXB-1047