0

I need to generate java classes for 3rd party schema I received (and unfortunately cannot modify), that looks like that:

...
<xs:element name="ARec">
  <xs:complexType>
     <xs:sequence>
        <xs:element name="ARecTyp" />
        <xs:element name="AGrp"  />
        <xs:element name="AGrpId"  />
...

And using maven-jaxb2-plugin, I'm able to do that, but my classes has all them members declared as

@XmlElement(name = "ARecTyp", required = true)
protected Object aRecTyp; 

(which, I believe, is correct and default mapping of xs:anyType). But in reality these elements are all texts, and I'd like to have it bound to java.lang.String, not java.lang.Object.

I tried to add

<globalBindings>
    <javaType name="java.lang.String" xmlType="xs:anyType"/>
</globalBindings>

but that won't work, as xs:anyType is complexType, not simpleType, so I'm getting exception. Is there any other way of mapping such xs:element without specified type to String instead of Object?

Jakub
  • 165
  • 2
  • 9
  • If the generated schema is not precise enough, why not doing a processing which reads the generated schema and replace occurrences of`xs:anyType` by `xs:string` ? – davidxxx Oct 31 '16 at 11:02
  • Yes, I'm now running xslt for that, similar to [link](http://stackoverflow.com/questions/9548104/add-attribute-to-tag-with-xslt) but I'd like to know if there is better way to configure jaxb itself. – Jakub Oct 31 '16 at 11:47

0 Answers0