Closed thomasgermain closed 12 months ago
In your bindings file, the path for the MyElement
binding needs to include the sub-path for the anonymous complex type:
my-binding.xjb
<?xml version="1.0" encoding="UTF-8"?>
<jxb:bindings
version="3.0"
xmlns:jxb="https://jakarta.ee/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:inheritance="http://jvnet.org/basicjaxb/xjc/inheritance"
jxb:extensionBindingPrefixes="xjc">
<jxb:bindings schemaLocation="my-xsd.xsd" node="//xs:element[@name='MyElement']//xs:complexType">
<inheritance:implements>org.example.MyInterface</inheritance:implements>
</jxb:bindings>
<jxb:bindings schemaLocation="my-xsd.xsd" node="//xs:complexType[@name='MyComplexType']">
<inheritance:implements>org.example.MyInterface</inheritance:implements>
</jxb:bindings>
</jxb:bindings>
Working perfectly thanks !
Hello,
I'm trying have some generated class to implement a specific interface. It is working perfectly for
complextType
, but not forelement
.The following example generates two classes:
MyComplexType
andMyElement
, but onlyMyComplexType
implements the interface.Am I doing something wrong ?
my-xsd.xsd
my-binding.xjb
Real life problem is more complex because I'm receiving XML from third party partner and they are using
element
and, of course, I don't have control on the XML,By the way, thanks for your work. It's really painful to find working solution for jaxb 3+ and jakarta !