J
jacksu
I am new to use Castor, and stuck in one "simple issue". The
"simpleType" won't be generated by Castor, here is simplified version
of the xsd file.
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="mynamespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:simpleType name="MyType">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="14"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
And here is the ant build script:
<?xml version="1.0"?>
<project name="xsdtest" default="xsd2java">
<path id="classpath">
<fileset file="mylib/castor/lib/castor-1.0M1-
xml.jar" />
<fileset file="mylib/commons-logging.jar" />
<fileset dir="mylib/apache/xerces/lib">
<include name="*.jar" />
</fileset>
</path>
<target name="xsd2java">
<java
classname="org.exolab.castor.builder.SourceGenerator"
failonerror="true" fork="true">
<classpath refid="classpath" />
<classpath location="." />
<arg line="-types j2"/>
<arg line="-package gen" />
<arg line="-dest ." />
<arg line="-f" />
<arg line="-i b.xsd" />
</java>
</target>
</project>
"simpleType" won't be generated by Castor, here is simplified version
of the xsd file.
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="mynamespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:simpleType name="MyType">
<xsd:restriction base="xsd:string">
<xsd:maxLength value="14"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
And here is the ant build script:
<?xml version="1.0"?>
<project name="xsdtest" default="xsd2java">
<path id="classpath">
<fileset file="mylib/castor/lib/castor-1.0M1-
xml.jar" />
<fileset file="mylib/commons-logging.jar" />
<fileset dir="mylib/apache/xerces/lib">
<include name="*.jar" />
</fileset>
</path>
<target name="xsd2java">
<java
classname="org.exolab.castor.builder.SourceGenerator"
failonerror="true" fork="true">
<classpath refid="classpath" />
<classpath location="." />
<arg line="-types j2"/>
<arg line="-package gen" />
<arg line="-dest ." />
<arg line="-f" />
<arg line="-i b.xsd" />
</java>
</target>
</project>