Jaxb inheritance with multiple XSD files fails when 1 XSD file doesn't contain a tag

18 Views Asked by At

I have a directory with 3 XSD files. 2 of the 3 XSD contain a ComplexType field with the name DetailInformation . For this 2 XSD's I want to create an interface on top of it and let it inherit.

I tried to create following binding.xml file:

<jxb:bindings   xmlns:jxb="http://java.sun.com/xml/ns/jaxb"   xmlns:xs="http://www.w3.org/2001/XMLSchema"   xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance"   jxb:extensionBindingPrefixes="inheritance"   jxb:version="2.1">     
   <jxb:bindings schemaLocation="{file}">         
      <jxb:bindings node="//xs:complexType[@name='DetailInformation']">                 
            <inheritance:implements>com.theapplication.interfaces.Details</inheritance:implements>           
      </jxb:bindings>     
   </jxb:bindings> 
</jxb:bindings>

But the XSD which doesn't contain the DetailInformation, fails during maven compile: com.sun.istack.SAXParseException2: XPath evaluation of "//xs:complexType[@name='DetailInformation']" results in empty target node

Is there a way to make this inheritance optional, that only if an XSD contains a tag with the value 'DetailInformation', it will inherit and otherwise no inheritance will be created?

0

There are 0 best solutions below