Given a Dataset XSD file, is it possible to generate java classes, that don't make use of System.Data? I've tried running a test using JAXB's XJC tool, but it doesn't produce anything terribly useful.
给定一个数据集XSD文件,是否可以生成不使用System.Data的java类?我已经尝试使用JAXB的XJC工具运行测试,但它没有产生任何非常有用的东西。
Update: I've tried XmlBeans also, following Fernando's suggestion, and it generates something similar to the XJC output - that is, class representations of the tables, but without any columns, constraints, or rows. I can add these things in a facade, but ideally they would be generated by whatever XSD compiler was used.
更新:我也按照Fernando的建议尝试了XmlBeans,它生成类似于XJC输出的东西 - 即表的类表示,但没有任何列,约束或行。我可以在外观中添加这些东西,但理想情况下它们将由使用的任何XSD编译器生成。
1 个解决方案
#1
You could try XMLBeans instead of JAXB API. You can invoke it be means of command line command or just use an ANT script. I past the part of a build.xml file that invokes XMLBeans to compile XSD to a jar file.
您可以尝试使用XMLBeans而不是JAXB API。您可以通过命令行命令或仅使用ANT脚本来调用它。我通过build.xml文件的一部分,该文件调用XMLBeans将XSD编译为jar文件。
<taskdef name="xmlbean" classname="org.apache.xmlbeans.impl.tool.XMLBean" classpathref="classpath"/>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- Crea y compila las clases del modelo -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<target name="build" description="--> crea las clases a partir del schema">
<!-- Borra los fuentes del modelo -->
<delete quiet="true" dir="${build.dir}/src" />
<mkdir dir="${build.classes}"/>
<!-- Construye fuentes asociadas y crea las clases -->
<xmlbean srcgendir="${build.dir}/src" classpathref="classpath" classgendir="${build.classes}">
<fileset dir="${src.dir}" excludes="**/*.xsd"/>
<fileset dir="${schemas.dir}" includes="**/*.*"/>
</xmlbean>
<javac srcdir="${src.dir}"
destdir="${build.classes}"
encoding="Windows-1252"
debug="${debug}"
debuglevel="${debuglevel}"
deprecation="${deprecation}"
verbose="${verbose}"
optimize="${optimize}"
source="${source}"
target="${target}">
<classpath refid="classpath" />
</javac>
</target>
#1
You could try XMLBeans instead of JAXB API. You can invoke it be means of command line command or just use an ANT script. I past the part of a build.xml file that invokes XMLBeans to compile XSD to a jar file.
您可以尝试使用XMLBeans而不是JAXB API。您可以通过命令行命令或仅使用ANT脚本来调用它。我通过build.xml文件的一部分,该文件调用XMLBeans将XSD编译为jar文件。
<taskdef name="xmlbean" classname="org.apache.xmlbeans.impl.tool.XMLBean" classpathref="classpath"/>
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<!-- Crea y compila las clases del modelo -->
<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
<target name="build" description="--> crea las clases a partir del schema">
<!-- Borra los fuentes del modelo -->
<delete quiet="true" dir="${build.dir}/src" />
<mkdir dir="${build.classes}"/>
<!-- Construye fuentes asociadas y crea las clases -->
<xmlbean srcgendir="${build.dir}/src" classpathref="classpath" classgendir="${build.classes}">
<fileset dir="${src.dir}" excludes="**/*.xsd"/>
<fileset dir="${schemas.dir}" includes="**/*.*"/>
</xmlbean>
<javac srcdir="${src.dir}"
destdir="${build.classes}"
encoding="Windows-1252"
debug="${debug}"
debuglevel="${debuglevel}"
deprecation="${deprecation}"
verbose="${verbose}"
optimize="${optimize}"
source="${source}"
target="${target}">
<classpath refid="classpath" />
</javac>
</target>