Last active
December 27, 2015 13:18
-
-
Save payliu/7331894 to your computer and use it in GitHub Desktop.
JAXB, xsd to java with binding configuration file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<jxb:bindings | |
xmlns:xsd="http://www.w3.org/2001/XMLSchema" | |
xmlns:jxb="http://java.sun.com/xml/ns/jaxb" | |
version="2.1"> | |
<jxb:bindings schemaLocation="Recipe.xsd"> | |
<jxb:bindings node="//xsd:element[@name='Currency']"> | |
<jxb:class ref="com.sample.finance.common.CurrencyCodeEnum"/> | |
</jxb:bindings> | |
</jxb:bindings> | |
</jxb:bindings> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" | |
targetNamespace="urn:com:sample:common" | |
xmlns="urn:com:sample:common" | |
elementFormDefault="qualified" | |
attributeFormDefault="unqualified"> | |
<!-- here, declare namespace: targetNamespace and xmlns--> | |
<xsd:simpleType name="CurrencyCodeEnum"> | |
<xsd:restriction base="xsd:string"> | |
<xsd:minLength value="3"/> | |
<xsd:maxLength value="3"/> | |
<xsd:pattern value=""/> | |
<xsd:enumeration value="AED"/> | |
<xsd:enumeration value="AFN"/> | |
<xsd:enumeration value="ALL"/> | |
<xsd:enumeration value="AMD"/> | |
</xsd:restriction> | |
</xsd:simpleType> | |
</xsd:schema> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
output='gen' | |
rm -rf $output | |
mkdir $output | |
xjc -d $output common.xsd | |
xjc -d $output Recipe.xsd -b bindings.xjb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" | |
xmlns="urn:com:sample:Finance" | |
targetNamespace="urn:com:sample:Finance" | |
elementFormDefault="qualified" | |
attributeFormDefault="unqualified"> | |
<xsd:complexType name="Amount"> | |
<xsd:sequence> | |
<xsd:element name="Currency" /> | |
</xsd:sequence> | |
</xsd:complexType> | |
</xsd:schema> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment