I'm using the org.jvnet.jaxb2.maven2:maven-jaxb2-plugin to create POJOs from XSD schema files.
Now I want to insert something like a custom setter. It should trim all Strings and should remove certain characters.
Do you know how to do this?
The XJB file:
<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings version="2.0" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc">
<jaxb:bindings schemaLocation="my-schema-xml4.xsd" node="/xs:schema">
<xjc:javaType name="java.lang.String" adapter="my.StringAdapter" />
</jaxb:bindings>
</jaxb:bindings>
Solution for binding Java types:
<?xml version="1.0" encoding="UTF-8" ?>
<bindings version="2.0" xmlns="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">
<bindings schemaLocation="mySchema-xml4.xsd" node="/xs:schema">
<globalBindings>
<xjc:javaType name="java.lang.String" xmlType="xs:string"
adapter="com.name.MyAdapter" />
<xjc:javaType name="java.lang.String" xmlType="xs:anySimpleType"
adapter="com.name.MyAdapter" />
</globalBindings>
</bindings>
</bindings>
But the @XmlJavaTypeAdapter
still isn't added to the content
property in nodes with mixed content, although the property has the type java.lang.String
.