问题
I have the following xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:any processContents="skip" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
and the following bindings:
<jxb:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb" version="2.1">
<jxb:bindings schemaLocation="format.xsd">
<jxb:bindings node="//xs:any">
<jxb:property>
<jxb:baseType>
<jxb:javaType name="org.w3c.dom.Element"
parseMethod="leif.ElementFormatter.parseElement"
printMethod="leif.ElementFormatter.printString" />
</jxb:baseType>
</jxb:property>
</jxb:bindings>
</jxb:bindings>
</jxb:bindings>
But when I run xjc...xjc -p leif -b bindings.xml format.xsd
I get the following errors:
parsing a schema...
[ERROR] compiler was unable to honor this javaType customization. It is attached to a wrong place, or its inconsistent with other bindings.
line 9 of file:/C:/Users/leif/workspace/doughan/src/main/resources/bindings.xml
[ERROR] (the above customization is attached to the following location in the schema)
line 7 of file:/C:/Users/leif/workspace/doughan/src/main/resources/format.xsd
Failed to parse a schema.
It happens only when defining javaType
for an xs:any
, and when I change it to xs:element
it works. But I really need it to be xs:any
.
My goal is to get a class like that:
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Root {
@XmlJavaTypeAdapter(Adapter1.class)
@XmlAnyElement
String any;
}
来源:https://stackoverflow.com/questions/29988023/getting-compiler-was-unable-to-honor-this-javatype-customization-with-xsany