I'm fairly new to jaxme and tried first to run an example. I copied the Ant task from "The JaxMe 2 manual" and modified a little with the paths.  I also added a <project> tag to the ant build file because it gives an error  "Unexpected element "target" target" when I first compiled it.
 
I don't know why it complains my XSD about "the type bookType is not defined."   It looks the bookType is defined.  Here's the error message:
 
"build.xml" 31: At file:/C:/jaxme/books.xsd, line 11, column 93: At file:/C:/jaxme/books.xsd, line 11, column 93: Invalid element: The type bookType is not defined. at line 31
 
The schemas file is pasted below.  The Ant file is pasted at the end too.
 
Thank you for any help.
 
Shaoguang
 
<?xml version="1.0" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
  targetNamespace="com.jaxme"
  jaxb:version="1.0">
  <xs:element name="Collection">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="books">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="book" type="bookType" minOccurs="1" maxOccurs="unbounded" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:complexType name="bookType">
    <xs:sequence>
      <xs:element name="name" type="xs:string" />
      <xs:element name="ISBN" type="xs:long" />
      <xs:element name="price" type="xs:string" />
      <xs:element name="authors">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="authorName" type="xs:string" minOccurs="1" maxOccurs="unbounded" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
      <xs:element name="description" type="xs:string" minOccurs="0" />
      <xs:element name="promotion">
        <xs:complexType>
         <xs:choice>
           <xs:element name="Discount" type="xs:string" />
           <xs:element name="None" type="xs:string" />
         </xs:choice>
        </xs:complexType>
      </xs:element>
      <xs:element name="publicationDate" type="xs:date" />
      <xs:element name="bookCategory">
        <xs:simpleType>
        <xs:restriction base="xs:NCName">
          <xs:enumeration value="magazine" />
          <xs:enumeration value="novel" />
          <xs:enumeration value="fiction" />
          <xs:enumeration value="other" />
        </xs:restriction>
        </xs:simpleType>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="itemId" type="xs:string" />
  </xs:complexType>
 
  <xs:simpleType name="bookCategoryType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="magazine" />
      <xs:enumeration value="novel" />
      <xs:enumeration value="fiction" />
      <xs:enumeration value="other" />
    </xs:restriction>
  </xs:simpleType>
</xs:schema>
 
// Ant file
 
<?xml version="1.0" ?>
<project name="generic" default="task1" basedir=".">
<target name="task1">  //<target name="taskdef">  
      <path id="com.jaxme">
        <pathelement location="C:\ws-jaxme-0.5\ws-jaxme-0.5\lib\jaxme2-0.5.jar"/>
        <pathelement location="C:\ws-jaxme-0.5\ws-jaxme-0.5\lib\jaxmejs-0.5.jar"/>
        <pathelement location="C:\ws-jaxme-0.5\ws-jaxme-0.5\lib\jaxmexs-0.5.jar"/>
        <pathelement location="C:\ws-jaxme-0.5\ws-jaxme-0.5\lib\jaxmeapi-0.5.jar"/>
      </path>
     
      <taskdef name="xjc"
        classname="org.apache.ws.jaxme.generator.XJCTask"
        classpathref="com.jaxme"/>
      
      <xjc schema="c:/jaxme/books.xsd"  target="c:/jaxme/src">
        <produces includes="com/jaxme/*.java"/>
      </xjc>
    </target>
</project>

Reply via email to