users@jaxb.java.net

Newbie help

From: Mitch Claborn <mitch_at_claborn.net>
Date: Sun, 14 Oct 2007 13:29:20 -0500 (CDT)

I need some help getting started with JAXB. I'm using version 2.1.

I have an existing set of Java classes that I want to load from an XML
file. I've manually created a schema file with generateValueClass="false"
and the xjc compiler generates interfaces and also some "Impl" classes
which implement the interfaces. How do I indicate to the xjc program to
use my existing classes as the implementations instead of the generated
"Impl" classes?

Or is there a better way to do this? I saw a reference to the
JavaCompiler utility but can't find any examples on how to use it.

Here is the xsd that I have been playing with:


<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
           xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
           jaxb:extensionBindingPrefixes="xjc"
           xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.1">
  <xsd:annotation>
    <xsd:documentation xml:lang="en">
     W3C XML Schema for surveys - use with JAXB
    </xsd:documentation>
    <xsd:appinfo>
      <jaxb:globalBindings
          collectionType="java.util.Vector"
          enableValidation="true"
          generateValueClass="false"
>
      </jaxb:globalBindings>
    </xsd:appinfo>
  </xsd:annotation>

  <xsd:element name="survey">
    <xsd:complexType>
      <xsd:attribute name="versionID" type="xsd:int" />
    </xsd:complexType>
  </xsd:element>

</xsd:schema>



-- 
Mitch Claborn
mitch_at_claborn.net