File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Cannot compile XSD using JAXB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Cannot compile XSD using JAXB" Watch "Cannot compile XSD using JAXB" New topic

Cannot compile XSD using JAXB

mou haj
Ranch Hand

Joined: Sep 12, 2001
Posts: 81
I have a a couple of XSDs and a common XSD is reffered in all XSDs and I cannot compile them to a class file:

My XSD :
<?xml version="1.0" encoding="UTF-8"?>
<!--W3C Schema generated by XMLSPY v2004 rel. 4 U (>
<xs:schema targetNamespace="" elementFormDefault="qualified" attributeFormDefault="unqualified" xmlns:xs="" xmlns="">
This is the XML Schema for Monarch Interface - Shared Stimulus
<xs:element name="SharedStimulus">
<xs:complexType mixed="true">
<xs:element name="SharedStimulusSpec" type="ICommon.ctSSSpecType"/>
<xs:element name="Passage" type="ICommon.ctElementType" minOccurs="0"/>
<xs:element name="OtherSharedStimulus" type="ICommon.ctElementType" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="SourceDoc" type="ICommon.ctSourceDocType"/>
<xs:element name="Renditions" type="ICommon.ctRenditionsType"/>
<xs:attribute name="MonarchId" type="xs:string" use="required"/>
<xs:attribute name="ExternalId" type="xs:string" use="required"/>
<xs:attribute name="type" type="ICommon.stSharedStimulusType" use="required"/>
<xs:attribute name="name" type="xs:string" use="optional"/>
<xs:attribute name="title" type="xs:string" use="optional"/>
<xs:attribute name="author" type="xs:string" use="optional"/>
<xs:attribute name="copyright" type="xs:string" use="optional"/>
<xs:attribute name="PatternIndicator" type="ICommon.stBoolean"/>

You can see in "<xs:element name="SourceDoc" type="ICommon.ctSourceDocType"/>" ICommon referred which is another XSD (ICommon.xd)

I am trying to comiple them using the build.xml
<?xml version="1.0"?>

Copyright 2003 Sun Microsystems, Inc. All rights reserved.

<project basedir="." default="run">

<!-- if you are not running from $JWSDP_HOME/jaxb/samples AND you
are using your own version of Ant, then you need to specify
"ant -Djwsdp.home=..." -->

<property name="modelMisc.classes" value="C:/jwsdp-1.3/jwsdp-1.3/jaxb/samples/unmarshal-read/classes" />
<property name="modelMisc.outputJar" value="modelMisc.jar" />
<property name="jwsdp.home" value="C:/jwsdp-1.3/jwsdp-1.3/" />
<property name="jaxb.home" value="C:/jwsdp-1.3/jwsdp-1.3/jaxb/" />

<path id="classpath">
<pathelement path="." />
<!-- for use with bundled ant -->
<fileset dir="${jwsdp.home}" includes="jaxb/lib/*.jar" />
<fileset dir="${jwsdp.home}" includes="jwsdp-shared/lib/*.jar" />
<fileset dir="${jwsdp.home}" includes="jaxp/lib/**/*.jar" />
<fileset dir="${jaxb.home}" includes="lib/*.jar" />


<taskdef name="xjc" classname="">

<classpath refid="classpath" />

<!-- compile Java source files -->
<target name="compile">

<!-- generate the Java content classes from the schema -->
<echo message="Compiling the schema..."/>

<xjc target="." package="primer.po" >
<schema dir="." includes="SharedStimulusInterface.xsd" />
<arg value="-nv" />


<!-- generate the javadocs from the content classes -->
<mkdir dir="docs/api"/>
<javadoc packagenames="primer.po"
windowtitle="Generated Interfaces for po.xsd">
<classpath refid="classpath" />

<!-- compile all of the java sources -->
<echo message="Compiling the java source files..."/>
<javac srcdir="." destdir="./classes" debug="on">
<classpath refid="classpath" />

<zip basedir="${modelMisc.classes}" zipfile="${modelMisc.outputJar}" encoding="UTF8"/> <!-- JARs filenames are encoded UTF8 -->




Please help, This build file compiles XSDs (where no other XSD has been reffered to).. but is failing when one xsd ia calling another XSD.

Any kind of help is appreciated.

I agree. Here's the link:
subject: Cannot compile XSD using JAXB