Closed Vampire closed 9 months ago
Can you share your code? We do episodes+inheritance. We place the inheritance rules in a jaxb-bindings file instead of the schema, and we use catalogs for namespace replacement.
Find attached a showcase.zip that demoes the problem.
Just unpack it and execute gradlew showcase
in it.
@Vampire thanks for the share. In case you want to know, I managed to make your showcase works with the following adjustements :
foo.xsd
<xs:simpleType name="foo">
<xs:restriction base="xs:string">
<xs:enumeration value="FOO"/>
<xs:enumeration value="BAR"/>
</xs:restriction>
</xs:simpleType>
foo.xjb
binding file with inheritance customization<jaxb:bindings
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:inheritance="http://jaxb2-commons.dev.java.net/basic/inheritance"
jaxb:extensionBindingPrefixes="inheritance"
jaxb:version="2.1">
<jaxb:bindings schemaLocation="foo.xsd" node="/xsd:schema">
<jaxb:bindings node="xsd:simpleType[@name='foo']">
<inheritance:implements>baz.Baz</inheritance:implements>
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
"binding"("file" to "foo.xjb")
I got the following generated with in bar-dest
ObjectFactory
refering to bar
Thanks for the work-around. It would still be nice if it worked with the inline definition, because having it in an extra file decreases readability and maintainability imho. But at least if we need to have this constellation, I now have a work-around in the backhand, thanks. Currently, I only had it while playing around and the actual case where he have it, inheritance is not used so far. :-)
Thanks for the work-around. It would still be nice if it worked with the inline definition, because having it in an extra file decreases readability and maintainability imho. But at least if we need to have this constellation, I now have a work-around in the backhand, thanks. Currently, I only had it while playing around and the actual case where he have it, inheritance is not used so far. :-)
@Vampire you're welcome
I found that in jaxb-annotate of highsource with same problem : https://github.com/highsource/jaxb2-annotate-plugin/issues/49
Seems like @highsource did know what could be done to solve the problem (but not giving hint on it - and sadly no more there to tell 😔) and also provide the same workaround as I do.
I'll have to debug to see if something's jumps out from the code. In the meantime, you still can use the workaround provided
Hi @Vampire,
Just made a PR in jaxb-ri to fix the above common problem with episode / inlined-plugin-customization in xsd.
Hi @Vampire
This is part of the release in 4.0.2 of jaxb-tools
Could you give it a try ?
We will backport this in v2 too soon
I tried to do something like shown at https://dzone.com/articles/reusing-generated-jaxb-classes, with the difference, that the imported schema uses
inheritance:implements
tags to define interfaces for some of the classes. But it seems this does not work properly. The other way around, havinginheritance:implements
in the importing schema works. When translating the imported schema with theinheritance:implements
tags, the episode file is generated. If I then want to translate the importing schema, giving the episode file as binding, I get complaints like these:Is this not supported? Can it be supported? Can I do something differently to make it work?