I have a huge xsd schema (the open source railML 2.2 format) for which I am trying to create a JPA annotated object model. I want to use HyperJAXB3 for that.
The XSD schema includes some <xs:any namespace="##other" />
elements. I have no chance to change the xsd files. The hyperjaxb compiler gives the error:
Class [org.railml.schemas._2013.TElementWithIDAndName] declares an attribute wildcard. This is currently not supported. See issue #46.
So Hyperjaxb seems to have problems with these wildcard constructions. I tried to add a hj:ignored
binding
<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
xmlns:hj="http://hyperjaxb3.jvnet.org/ejb/schemas/customizations"
version="2.1">
<!-- global bindings -->
<jaxb:globalBindings>
<xjc:simple />
</jaxb:globalBindings>
<jaxb:bindings
schemaLocation="genericRailML.xsd">
<jaxb:bindings node="//xs:schema//xs:complexType[@name='tElementWithIDAndName']//xs:sequence//xs:any">
<hj:ignored/>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
But then the compiler gives:
[ERROR] compiler was unable to honor ignored customization. It is attached to a wrong place, or its inconsistent with other bindings.
The referenced XSD part:
<xs:schema xmlns:rail="http://www.railml.org/schemas/2013" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:dc="http://purl.org/dc/elements/1.1/" targetNamespace="http://www.railml.org/schemas/2013" elementFormDefault="qualified" version="2.2">
...
<xs:complexType name="tElementWithIDAndName">
<xs:annotation>
<xs:documentation>generic base type, used for inheritance of many railML types</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="additionalName" type="rail:tAdditionalName" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
...
</xs:annotation>
</xs:element>
<xs:any namespace="##other" processContents="strict" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>provide an extension point for non-railML elements in foreign namespace</xs:documentation>
</xs:annotation>
</xs:any>
</xs:sequence>
<xs:attribute name="id" type="rail:tGenericID" use="required">
...
</xs:attribute>
...
</xs:complexType>
...
</xs:schema>
Is there a way to parse the XSD document with HyperJAXB or is there a way to bypass the xs:any
elements?