I am working on an internal undertaking in my trim clip at IBM that involves some marshalling of XML applying Java. The obvious campaigner is JAXB
which in the main plants really goodly. Nonetheless when it neglects, info on the web can be thwarting, saying you to repair it employing <jaxb:property>
but not really giving you any utile info. I acknowledge this is for a specific fault that I necessitated to doctor, but I make not believe it is uncommon.
Therefore I hold indited a short xsd instance that when run through xjc.sh
( or xjc.bat
on windows ) exhibits the same fault I was getting. The contents of the Dummy.xml
file are as follows ( sorry for format, wordpress not me! ):
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSc
<xsd:complexType name="complexTypeOne">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="value" type="simpleTypeOne"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:complexType name="complexTypeTwo">
<xsd:simpleContent>
<xsd:extension base="xsd:string">
<xsd:attribute name="value" type="simpleTypeTwo"/>
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
<xsd:simpleType name="simpleTypeTwo">
<xsd:restriction base="xsd:string">
<xsd:pattern value="[0123456789]+"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="simpleTypeOne">
<xsd:restriction base="xsd:token">
<xsd:enumeration value="exist"/>
<xsd:enumeration value="noexist"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
The Dummy.xml
file lies of two complexTypes with an property of the same name, not a vast job as the Java XML parsers run rather happily when validating XML, but when it comes to utilizing JAXB
codification contemporaries it go over. Just in case instance the same name is value and when run with xjc.sh
produces the undermentioned mistake:
Property "Value" is already defined. Use <jaxb:property> to resolve this conflict.
The mode to doctor this issue is so to apply a <jaxb:property>
ticket, and the mode I happened to restore this was applying an external bindings register. This file will detail alternate names to employ for the clashing names and will permit JAXB to parse without throwing mistakes. The bindings.xsd
can be chance here:
<jxb:bindings version="2.0"
xmlns:jxb="http://java.sun.com/xml/ns/j
xmlns:xsd="http://www.w3.org/2001/XMLSc
<jxb:bindings schemaLocation="Dummy.xml" node="/xsd:schema">
<jxb:bindings node="//xsd:complexType[@name='complexTy
<jxb:bindings node=".//xsd:attribute[@name='value']">
<jxb:property name="ValueToFixError1"/>
</jxb:bindings>
</jxb:bindings>
<jxb:bindings node="//xsd:complexType[@name='complexTy
<jxb:bindings node=".//xsd:attribute[@name='value']">
<jxb:property name="ValueToFixError2"/>
</jxb:bindings>
</jxb:bindings>
</jxb:bindings>
</jxb:bindings>
The bindings.xsd
delimits the xml file to do the adjustments to ( schemaLocation="Dummy.xml"
) and so specifies utilizing XPATH
notation the relevant values to alter. Fairly self explanatory if you can see the files for yourself, less so if you are simply sayed to apply
tickets! To stipulate the bindings.xsd
on the dictation line merely make: xjc.sh -b bindings.xsd Dummy.xml
which should now collect your codification!
Related posts:
Linwood Michigan loans




Infinite is still available for this Fri 's Monte Carlo/Awards Night at the 
