Last active
December 27, 2015 13:18
-
-
Save payliu/7331818 to your computer and use it in GitHub Desktop.
JAXB, xsd to java,
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 | |
# generate java to "gen" folder | |
xjc -d $output Recipe.xsd |
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" | |
xmlns:prefixName="urn:com:sample:common" | |
elementFormDefault="qualified" | |
attributeFormDefault="unqualified"> | |
<!-- here, see: 'xmlns:prefixName' --> | |
<xsd:import schemaLocation="common.xsd" namespace="urn:com:sample:common"/> <!-- add import here --> | |
<xsd:complexType name="Amount"> | |
<xsd:sequence> | |
<xsd:element name="Currency" | |
type="prefixName:CurrencyCodeEnum" /> <!-- imported type--> | |
</xsd:sequence> | |
</xsd:complexType> | |
</xsd:schema> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment