You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xmlbeans-cvs@xml.apache.org by da...@apache.org on 2003/11/03 22:58:52 UTC

cvs commit: xml-xmlbeans/v2/test/src/drt/drtcases BindingTests.java

davidbau    2003/11/03 13:58:52

  Modified:    v2       build.xml
               v2/src/binding/org/apache/xmlbeans/impl/binding/bts
                        JavaName.java PathBindingLoader.java
                        SimpleDocumentBinding.java XmlName.java
               v2/src/binding/org/apache/xmlbeans/impl/binding/compile
                        JAXRPCSchemaBinder.java Java2Schema.java
                        Java2SchemaTask.java JavaToSchemaInput.java
                        JavaToSchemaResult.java JavaToSchemaResultImpl.java
                        SchemaToJavaInput.java SchemaToJavaResult.java
               v2/src/configschema/schema binding-config.xsd
               v2/src/typeimpl/org/apache/xmlbeans/impl/schema
                        SchemaPropertyImpl.java
               v2/test/src/drt/drtcases BindingTests.java
  Added:       v2/src/binding/org/apache/xmlbeans/impl/binding/compile
                        SimpleJavaToSchemaResultCompiler.java
                        SimpleSchemaSourceSet.java
                        SimpleSchemaToJavaResultCompiler.java
                        SimpleTylarLoader.java
  Log:
  Filling in some of the compiletime abstractions.
  
  (1) input for schema compiles and java compiles (SchemaToJavaInput, JavaToSchemaInput)
  is now a "compilable" source set that knows how to produce both metadata and actual
  compiled output.
  
  (2) Changed the SimpleDocumentBinding to be indexed by element name and contain the
  element's type, rather than vice-versa, and changed the schema binder produce one
  just like the java binder.
  
  (3) Included "Simple" implementations for the basic things passed around at compiletime,
  so that the machinery is there to produce complete tylars with .class, .xsb, and
  binding-config.xml all "in the JAR".
  
  SimpleTylarLoader (for classloader, classpath, and builtin implementations)
  PathBindingLoader (classloader, classpath implementations added)
  SimpleSchemaSourceSet (simple implementation of SchemaToJavaInput)
  SimpleSchemaToJavaResultCompiler
  SimpleJavaToSchemaResultCompiler (empty right now)
  
  Code review: pcal (pending)
  Regression tests: passed
  
  Revision  Changes    Path
  1.13      +2 -1      xml-xmlbeans/v2/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/build.xml,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- build.xml	31 Oct 2003 22:23:25 -0000	1.12
  +++ build.xml	3 Nov 2003 21:58:51 -0000	1.13
  @@ -694,7 +694,7 @@
   
     <!-- binding target =============================================== -->
   
  -  <target name="binding.classes" depends="dirs, repackage.classes, typeimpl.classes, xmlpublic.classes, typestore.classes, configschema.classes, jam.classes">
  +  <target name="binding.classes" depends="dirs, repackage.classes, typeimpl.classes, xmlpublic.classes, typestore.classes, configschema.classes, xmlcomp.classes, jam.classes">
       <mkdir dir="build/classes/binding"/>
       <javac srcdir="src/binding" destdir="build/classes/binding" source="1.4" debug="on">
         <classpath>
  @@ -709,6 +709,7 @@
           <pathelement location="build/classes/toolschema"/>
           <pathelement location="build/classes/xsdschema"/>
           <pathelement location="build/classes/jam"/>
  +        <pathelement location="build/classes/xmlcomp"/>
         </classpath>
       </javac>
   
  
  
  
  1.4       +1 -1      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/JavaName.java
  
  Index: JavaName.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/JavaName.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JavaName.java	28 Oct 2003 17:51:26 -0000	1.3
  +++ JavaName.java	3 Nov 2003 21:58:51 -0000	1.4
  @@ -69,7 +69,7 @@
    * 
    * "x=org.apache.xmlbeans.XmlInt"
    */
  -public final class JavaName
  +public final class JavaName  // WARNING: this class will be renamed to "JavaTypeName"
   {
       private final String className;
       private final String arrayString;
  
  
  
  1.3       +64 -0     xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/PathBindingLoader.java
  
  Index: PathBindingLoader.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/PathBindingLoader.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PathBindingLoader.java	28 Oct 2003 17:51:26 -0000	1.2
  +++ PathBindingLoader.java	3 Nov 2003 21:58:51 -0000	1.3
  @@ -58,6 +58,8 @@
   import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
   import org.apache.xmlbeans.impl.binding.bts.BindingType;
   import org.apache.xmlbeans.impl.binding.bts.JavaName;
  +import org.apache.xmlbeans.impl.schema.FileResourceLoader;
  +import org.apache.xmlbeans.x2003.x09.bindingConfig.BindingConfigDocument;
   
   import java.util.ArrayList;
   import java.util.List;
  @@ -66,6 +68,11 @@
   import java.util.Collections;
   import java.util.Collection;
   import java.util.Arrays;
  +import java.util.Enumeration;
  +import java.io.IOException;
  +import java.io.File;
  +import java.io.InputStream;
  +import java.net.URL;
   
   /**
    * A binding loader impl with the ability to chain together a path
  @@ -174,5 +181,62 @@
           }
           return null;
       }
  +    
  +    public static final String STANDARD_PATH = "org/apache/xmlbeans/binding-config.xml";
  +    
  +    public static BindingLoader forClassLoader(ClassLoader loader)
  +    {
  +        Enumeration i;
  +
  +        try
  +        {
  +            i = loader.getResources(STANDARD_PATH);
  +        }
  +        catch (IOException e)
  +        {
  +            throw (IllegalStateException)(new IllegalStateException().initCause(e));
  +        }
  +
  +        URL resource = null;
  +
  +        List files = new ArrayList();
  +        
  +        try
  +        {
  +            while (i.hasMoreElements())
  +            {
  +                resource = (URL)i.nextElement();
  +                files.add(BindingFile.forDoc(BindingConfigDocument.Factory.parse(resource)));
  +            }
  +        }
  +        catch (Exception e)
  +        {
  +            throw (IllegalStateException)(new IllegalStateException("Problem resolving " + resource).initCause(e));
  +        }
  +        
  +        return forPath(files);
  +    }
  +    
  +    public static BindingLoader forClasspath(File[] jarsOrDirs)
  +    {
  +        List files = new ArrayList();
  +        
  +        try
  +        {
  +            for (int i = 0; i < jarsOrDirs.length; i++)
  +            {
  +                FileResourceLoader rl = new FileResourceLoader(jarsOrDirs[i]);
  +                InputStream resource = rl.getResourceAsStream(STANDARD_PATH);
  +                files.add(BindingFile.forDoc(BindingConfigDocument.Factory.parse(resource)));
  +            }
  +        }
  +        catch (Exception e)
  +        {
  +            throw (IllegalStateException)(new IllegalStateException("Problem resolving files").initCause(e));
  +        }
  +        
  +        return forPath(files);
  +    }
  +        
   }
   
  
  
  
  1.3       +34 -32    xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/SimpleDocumentBinding.java
  
  Index: SimpleDocumentBinding.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/SimpleDocumentBinding.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SimpleDocumentBinding.java	31 Oct 2003 21:07:32 -0000	1.2
  +++ SimpleDocumentBinding.java	3 Nov 2003 21:58:51 -0000	1.3
  @@ -55,42 +55,44 @@
   */
   package org.apache.xmlbeans.impl.binding.bts;
   
  -import java.util.*;
  -import javax.xml.namespace.QName;
  -
   /**
    * BindingType for root elements.
    */
   public class SimpleDocumentBinding extends BindingType
   {
  -  private String mElementName = "";
  -
  -  public SimpleDocumentBinding(BindingTypeName btname, String elementName) {
  -    super(btname);
  -    System.out.println("++"+elementName);
  -    mElementName = elementName;
  -  }
  -
  -  public SimpleDocumentBinding(org.apache.xmlbeans.x2003.x09.bindingConfig.SimpleDocumentBinding node)
  -  {
  -    super(node);
  -    mElementName = node.getElementName();
  -  }
  -
  -  /**
  -   * This function copies an instance back out to the relevant part of the XML file.
  -   *
  -   * Subclasses should override and call super.write first.
  -   */
  -  protected org.apache.xmlbeans.x2003.x09.bindingConfig.BindingType write(org.apache.xmlbeans.x2003.x09.bindingConfig.BindingType node)
  -  {
  -    org.apache.xmlbeans.x2003.x09.bindingConfig.SimpleDocumentBinding sdbNode =
  -            (org.apache.xmlbeans.x2003.x09.bindingConfig.SimpleDocumentBinding)super.write(node);
  -    sdbNode.setElementName(mElementName);
  -    return sdbNode;
  -  }
  -
  -  public String getElementName() { return mElementName; }
  +    private XmlName typeOfElement;
   
  -  public void setElementName(String name) { mElementName = name; }
  +    public SimpleDocumentBinding(BindingTypeName btname)
  +    {
  +        super(btname);
  +    }
  +
  +    public SimpleDocumentBinding(org.apache.xmlbeans.x2003.x09.bindingConfig.SimpleDocumentBinding node)
  +    {
  +        super(node);
  +        typeOfElement = XmlName.forString(node.getTypeOfElement());
  +    }
  +
  +    /**
  +     * This function copies an instance back out to the relevant part of the XML file.
  +     *
  +     * Subclasses should override and call super.write first.
  +     */
  +    protected org.apache.xmlbeans.x2003.x09.bindingConfig.BindingType write(org.apache.xmlbeans.x2003.x09.bindingConfig.BindingType node)
  +    {
  +        org.apache.xmlbeans.x2003.x09.bindingConfig.SimpleDocumentBinding sdbNode =
  +                (org.apache.xmlbeans.x2003.x09.bindingConfig.SimpleDocumentBinding) super.write(node);
  +        sdbNode.setTypeOfElement(typeOfElement.toString());
  +        return sdbNode;
  +    }
  +
  +    public XmlName getTypeOfElement()
  +    {
  +        return typeOfElement;
  +    }
  +
  +    public void setTypeOfElement(XmlName typeOfElement)
  +    {
  +        this.typeOfElement = typeOfElement;
  +    }
   }
  
  
  
  1.3       +1 -1      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/XmlName.java
  
  Index: XmlName.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/bts/XmlName.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XmlName.java	27 Oct 2003 19:17:21 -0000	1.2
  +++ XmlName.java	3 Nov 2003 21:58:51 -0000	1.3
  @@ -86,7 +86,7 @@
    * Has the following signature:
    *     y.3|y.2|y.4|t=drg@foobar
    */
  -public class XmlName
  +public class XmlName // WARNING: this class will be renamed to "XmlTypeName"
   {
       private String namespace;
       private String path;
  
  
  
  1.4       +22 -8     xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/JAXRPCSchemaBinder.java
  
  Index: JAXRPCSchemaBinder.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/JAXRPCSchemaBinder.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- JAXRPCSchemaBinder.java	29 Oct 2003 20:32:03 -0000	1.3
  +++ JAXRPCSchemaBinder.java	3 Nov 2003 21:58:51 -0000	1.4
  @@ -65,6 +65,7 @@
   import org.apache.xmlbeans.impl.binding.bts.QNameProperty;
   import org.apache.xmlbeans.impl.binding.bts.SimpleBindingType;
   import org.apache.xmlbeans.impl.binding.bts.BindingTypeName;
  +import org.apache.xmlbeans.impl.binding.bts.SimpleDocumentBinding;
   import org.apache.xmlbeans.impl.binding.compile.BindingFileGenerator;
   import org.apache.xmlbeans.impl.binding.compile.JavaCodeGenerator;
   import org.apache.xmlbeans.impl.binding.compile.JavaCodePrinter;
  @@ -110,22 +111,24 @@
       private BindingLoader path;
       private int structureCount;
       private BindingFile bindingFile = new BindingFile();
  +    private SchemaToJavaInput sourceSet;
   
  -    private JAXRPCSchemaBinder(SchemaTypeSystem sts, BindingLoader path)
  +    private JAXRPCSchemaBinder(SchemaToJavaInput input)
       {
  -        this.sts = sts;
  -        this.path = path;
  +        this.sourceSet = input;
  +        this.sts = input.getSchemaTypeSystem();
  +        this.path = input.getTylarLoader().getBindingLoader();
       }
       
       /**
        * Generates a binding for the given set of schema types.
        * 
  -     * Defer to any previously defined bindings on the BindingLoader path
  +     * Defer to any previously defined bindings on the TylarLoader path
        * supplied.
        */
  -    public static SchemaToJavaResult bind(SchemaTypeSystem sts, BindingLoader path)
  +    public static SchemaToJavaResult bind(SchemaToJavaInput input)
       {
  -        JAXRPCSchemaBinder binder = new JAXRPCSchemaBinder(sts, path);
  +        JAXRPCSchemaBinder binder = new JAXRPCSchemaBinder(input);
           binder.bind();
           return binder;
       }
  @@ -311,7 +314,6 @@
           switch (scratch.getCategory())
           {
               case Scratch.ATOMIC_TYPE:
  -            case Scratch.ELEMENT:
               case Scratch.SOAPARRAY_REF:
               case Scratch.ATTRIBUTE:
                   SimpleBindingType simpleResult = new SimpleBindingType(btName);
  @@ -320,6 +322,13 @@
                   bindingFile.addBindingType(simpleResult, shouldBeFromJavaDefault(btName), true);
                   break;
                   
  +            case Scratch.ELEMENT:
  +                SimpleDocumentBinding docResult = new SimpleDocumentBinding(btName);
  +                docResult.setTypeOfElement(scratch.getAsIf());
  +                scratch.setBindingType(docResult);
  +                bindingFile.addBindingType(docResult, shouldBeFromJavaDefault(btName), true);
  +                break;
  +                
               case Scratch.STRUCT_TYPE:
                   ByNameBean byNameResult = new ByNameBean(btName);
                   scratch.setBindingType(byNameResult);
  @@ -995,7 +1004,7 @@
                       baseJavaname = null;
               }
               
  -            line("package " + packageName);
  +            line("package " + packageName + ";");
               line();
               javadoc("Generated from schema type " + scratch.getXmlName());
               line("class " + shortClassName + (baseJavaname != null ? " extends " + baseJavaname : ""));
  @@ -1063,6 +1072,11 @@
               seenNames.add(fieldName);
               return fieldName;
           }
  +    }
  +
  +    public SchemaToJavaInput getSchemaSourceSet()
  +    {
  +        return sourceSet;
       }
   
       /**
  
  
  
  1.6       +6 -2      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/Java2Schema.java
  
  Index: Java2Schema.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/Java2Schema.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Java2Schema.java	31 Oct 2003 21:07:32 -0000	1.5
  +++ Java2Schema.java	3 Nov 2003 21:58:51 -0000	1.6
  @@ -118,11 +118,12 @@
      * Does the binding work and returns the result.
      */
     public JavaToSchemaResult bind() {
  -    final JavaToSchemaResultImpl out = new JavaToSchemaResultImpl();
  +    final JavaToSchemaResultImpl out = new JavaToSchemaResultImpl(mInput);
       bind(mInput.getJClasses(),out);
       return new JavaToSchemaResult() {
         public BindingFileGenerator getBindingFileGenerator() { return out; }
         public SchemaGenerator getSchemaGenerator() { return out; }
  +      public JavaToSchemaInput getJavaSourceSet() { return out.getJavaSourceSet(); }
       };
     }
   
  @@ -175,7 +176,10 @@
       mBindingFile.addBindingType(bindType,true,true);
       String rootName = getAnnotation(clazz,TAG_CT_ROOT,null);
       if (rootName != null) {
  -      SimpleDocumentBinding sdb = new SimpleDocumentBinding(btname,rootName);
  +      QName rootQName = new QName(tns, rootName);
  +      BindingTypeName docBtName = BindingTypeName.forPair(getJavaName(clazz), XmlName.forGlobalName(XmlName.ELEMENT, rootQName));
  +      SimpleDocumentBinding sdb = new SimpleDocumentBinding(docBtName);
  +      sdb.setTypeOfElement(btname.getXmlName());
         mBindingFile.addBindingType(sdb,true,true);
       }
       // run through the class' properties to populate the binding and xsdtypes
  
  
  
  1.3       +1 -0      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/Java2SchemaTask.java
  
  Index: Java2SchemaTask.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/Java2SchemaTask.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Java2SchemaTask.java	31 Oct 2003 21:07:32 -0000	1.2
  +++ Java2SchemaTask.java	3 Nov 2003 21:58:51 -0000	1.3
  @@ -173,6 +173,7 @@
       JavaToSchemaInput input = new JavaToSchemaInput() {
         public JClass[] getJClasses() { return classes; }
         public TylarLoader getTylarLoader() { return null; }
  +      public void compileJavaToBinaries(File classesDir) {}
       };
       Java2Schema j2b = new Java2Schema(input);
       TylarBuilder tb = new ExplodedTylarBuilder(mDestDir);
  
  
  
  1.3       +9 -1      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/JavaToSchemaInput.java
  
  Index: JavaToSchemaInput.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/JavaToSchemaInput.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JavaToSchemaInput.java	31 Oct 2003 21:07:32 -0000	1.2
  +++ JavaToSchemaInput.java	3 Nov 2003 21:58:51 -0000	1.3
  @@ -58,7 +58,9 @@
   
   import org.apache.xmlbeans.impl.jam.JClass;
   
  -public interface JavaToSchemaInput
  +import java.io.File;
  +
  +public interface JavaToSchemaInput  // WARNING: this class will be renamed to "JavaSourceSet"
   {
       /**
        * Returns the JClasses to be processed for binding.
  @@ -69,5 +71,11 @@
        * Returns the path used for resolving already-known bindings
        */
       TylarLoader getTylarLoader();
  +    
  +    /**
  +     * Compiles just the java code to binaries in the given directory.
  +     * Any generated schema or binding code isn't included in this compile. 
  +     */
  +    void compileJavaToBinaries(File classesDir);
       
   }
  
  
  
  1.2       +1 -0      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/JavaToSchemaResult.java
  
  Index: JavaToSchemaResult.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/JavaToSchemaResult.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JavaToSchemaResult.java	29 Oct 2003 20:32:03 -0000	1.1
  +++ JavaToSchemaResult.java	3 Nov 2003 21:58:51 -0000	1.2
  @@ -60,4 +60,5 @@
   {
       BindingFileGenerator getBindingFileGenerator();
       SchemaGenerator getSchemaGenerator();
  +    JavaToSchemaInput getJavaSourceSet();
   }
  
  
  
  1.2       +9 -0      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/JavaToSchemaResultImpl.java
  
  Index: JavaToSchemaResultImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/JavaToSchemaResultImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JavaToSchemaResultImpl.java	31 Oct 2003 21:07:32 -0000	1.1
  +++ JavaToSchemaResultImpl.java	3 Nov 2003 21:58:51 -0000	1.2
  @@ -84,6 +84,11 @@
   
     private Map mTNS2Schema = new HashMap();
     private List mBindingFiles = new ArrayList();
  +  private JavaToSchemaInput javaSourceSet;
  +    
  +  JavaToSchemaResultImpl(JavaToSchemaInput javaSourceSet) {
  +    this.javaSourceSet = javaSourceSet;
  +  }
   
     // ========================================================================
     // Package methods - called by Java2Schema
  @@ -96,6 +101,10 @@
   
     // REVIEW is there really any reason to allow more than one?
     /*package*/ void addBindingFile(BindingFile bf) { mBindingFiles.add(bf); }
  +    
  +  JavaToSchemaInput getJavaSourceSet() {
  +    return javaSourceSet;
  +  }
   
     // ========================================================================
     // SchemaGenerator implementation
  
  
  
  1.2       +9 -1      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/SchemaToJavaInput.java
  
  Index: SchemaToJavaInput.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/SchemaToJavaInput.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SchemaToJavaInput.java	29 Oct 2003 20:32:03 -0000	1.1
  +++ SchemaToJavaInput.java	3 Nov 2003 21:58:51 -0000	1.2
  @@ -58,7 +58,9 @@
   
   import org.apache.xmlbeans.SchemaTypeSystem;
   
  -public interface SchemaToJavaInput
  +import java.io.File;
  +
  +public interface SchemaToJavaInput // WARNING: this class will be renamed to "SchemaSourceSet"
   {
       /**
        * Returns a typesystem that contains all the schema types to be
  @@ -70,4 +72,10 @@
        * Returns the path used for resolving already-known bindings
        */
       TylarLoader getTylarLoader();
  +    
  +    /**
  +     * Compiles just the schema metadata to binaries in the given directory.
  +     * Any generated Java or binding code isn't included in this compile. 
  +     */
  +    void compileSchemaToBinaries(File classesDir);
   }
  
  
  
  1.2       +1 -0      xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/SchemaToJavaResult.java
  
  Index: SchemaToJavaResult.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/SchemaToJavaResult.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SchemaToJavaResult.java	27 Oct 2003 19:17:21 -0000	1.1
  +++ SchemaToJavaResult.java	3 Nov 2003 21:58:51 -0000	1.2
  @@ -69,4 +69,5 @@
   {
       BindingFileGenerator getBindingFileGenerator();
       JavaCodeGenerator getJavaCodeGenerator();
  +    SchemaToJavaInput getSchemaSourceSet();
   }
  
  
  
  1.1                  xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/SimpleJavaToSchemaResultCompiler.java
  
  Index: SimpleJavaToSchemaResultCompiler.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
  *
  * 3. The end-user documentation included with the redistribution,
  *    if any, must include the following acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
  *
  * 4. The names "Apache" and "Apache Software Foundation" must
  *    not be used to endorse or promote products derived from this
  *    software without prior written permission. For written
  *    permission, please contact apache@apache.org.
  *
  * 5. Products derived from this software may not be called "Apache
  *    XMLBeans", nor may "Apache" appear in their name, without prior
  *    written permission of the Apache Software Foundation.
  *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * ====================================================================
  *
  * This software consists of voluntary contributions made by many
  * individuals on behalf of the Apache Software Foundation and was
  * originally based on software copyright (c) 2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  
  package org.apache.xmlbeans.impl.binding.compile;
  
  public class SimpleJavaToSchemaResultCompiler
  {
      
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/SimpleSchemaSourceSet.java
  
  Index: SimpleSchemaSourceSet.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
  *
  * 3. The end-user documentation included with the redistribution,
  *    if any, must include the following acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
  *
  * 4. The names "Apache" and "Apache Software Foundation" must
  *    not be used to endorse or promote products derived from this
  *    software without prior written permission. For written
  *    permission, please contact apache@apache.org.
  *
  * 5. Products derived from this software may not be called "Apache
  *    XMLBeans", nor may "Apache" appear in their name, without prior
  *    written permission of the Apache Software Foundation.
  *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * ====================================================================
  *
  * This software consists of voluntary contributions made by many
  * individuals on behalf of the Apache Software Foundation and was
  * originally based on software copyright (c) 2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  
  package org.apache.xmlbeans.impl.binding.compile;
  
  import org.apache.xmlbeans.SchemaTypeSystem;
  import org.apache.xmlbeans.XmlBeans;
  import org.apache.xmlbeans.XmlObject;
  import org.apache.xmlbeans.XmlException;
  import org.apache.xmlbeans.impl.schema.SchemaTypeSystemImpl;
  import org.w3.x2001.xmlSchema.SchemaDocument;
  
  import java.io.File;
  import java.io.IOException;
  import java.io.ByteArrayOutputStream;
  import java.io.ByteArrayInputStream;
  import java.util.ArrayList;
  import java.util.Collection;
  
  public class SimpleSchemaSourceSet implements SchemaToJavaInput
  {
      private TylarLoader tylarLoader;
      private SchemaTypeSystem schemaTypeSystem;
  
      public SchemaTypeSystem getSchemaTypeSystem()
      {
          return schemaTypeSystem;
      }
  
      public TylarLoader getTylarLoader()
      {
          return tylarLoader;
      }
  
      public void compileSchemaToBinaries(File classesDir)
      {
          SchemaTypeSystemImpl impl = (SchemaTypeSystemImpl)schemaTypeSystem;
          impl.saveToDirectory(classesDir);
      }
  
      private SimpleSchemaSourceSet(SchemaTypeSystem schemaTypeSystem, TylarLoader tylarLoader)
      {
          this.tylarLoader = tylarLoader;
          this.schemaTypeSystem = schemaTypeSystem;
      }
  
      public static SchemaToJavaInput forFile(File xsdFilename) throws IOException, XmlException
      {
          SchemaTypeSystem sts = XmlBeans.compileXsd(new XmlObject[] { SchemaDocument.Factory.parse(xsdFilename) }, XmlBeans.getBuiltinTypeSystem(), null);
          return new SimpleSchemaSourceSet(sts, SimpleTylarLoader.forBuiltins());
      }
      
      public static SchemaToJavaInput forSchemaGenerator(SchemaGenerator generator, TylarLoader tylarLoader)
      {
          try
          {
              String[] namespaces = generator.getTargetNamespaces();
              Collection schemas = new ArrayList();
              for (int i = 0; i < namespaces.length; i++)
              {
                  ByteArrayOutputStream inMemoryBuffer = new ByteArrayOutputStream();
                  generator.printSchema(namespaces[i], inMemoryBuffer);
                  inMemoryBuffer.close();
                  ByteArrayInputStream input = new ByteArrayInputStream(inMemoryBuffer.toByteArray());
                  schemas.add(SchemaDocument.Factory.parse(input));
              }
              XmlObject [] sources = (XmlObject[])schemas.toArray(new XmlObject[schemas.size()]);
              SchemaTypeSystem sts = XmlBeans.compileXsd(sources, tylarLoader.getSchemaTypeLoader(), null);
              return new SimpleSchemaSourceSet(sts, tylarLoader);
          }
          catch (IOException e)
          {
              throw new RuntimeException(e);
          }
          catch (XmlException e)
          {
              throw (IllegalStateException)new IllegalStateException().initCause(e);
          }
      }
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/SimpleSchemaToJavaResultCompiler.java
  
  Index: SimpleSchemaToJavaResultCompiler.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
  *
  * 3. The end-user documentation included with the redistribution,
  *    if any, must include the following acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
  *
  * 4. The names "Apache" and "Apache Software Foundation" must
  *    not be used to endorse or promote products derived from this
  *    software without prior written permission. For written
  *    permission, please contact apache@apache.org.
  *
  * 5. Products derived from this software may not be called "Apache
  *    XMLBeans", nor may "Apache" appear in their name, without prior
  *    written permission of the Apache Software Foundation.
  *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * ====================================================================
  *
  * This software consists of voluntary contributions made by many
  * individuals on behalf of the Apache Software Foundation and was
  * originally based on software copyright (c) 2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  
  package org.apache.xmlbeans.impl.binding.compile;
  
  import org.apache.xmlbeans.impl.tool.CodeGenUtil;
  import org.apache.xmlbeans.impl.binding.bts.PathBindingLoader;
  
  import java.io.File;
  import java.io.IOException;
  import java.io.OutputStream;
  import java.io.FileOutputStream;
  import java.util.Collection;
  import java.util.Iterator;
  import java.util.ArrayList;
  import java.util.List;
  
  public class SimpleSchemaToJavaResultCompiler
  {
      public static class Params
      {
          private File outputJar;
  
          public File getOutputJar()
          {
              return outputJar;
          }
  
          public void setOutputJar(File outputJar)
          {
              this.outputJar = outputJar;
          }
      }
      
      public static void compile(SchemaToJavaResult sources, Params params) throws IOException
      {
          // first, pick temp directory
          File tempDir = createTempDir();
          File sourceDir = createDir(tempDir, "sources");
          File classDir = createDir(tempDir, "classes");
          
          // next, output all the .java files to the temp dir
          List javaFileList = new ArrayList();
          JavaCodeGenerator jcg = sources.getJavaCodeGenerator();
          Collection classNames = jcg.getToplevelClasses();
          for (Iterator i = classNames.iterator(); i.hasNext(); )
          {
              String className = (String)i.next();
              File javaFilename = ensureDir(sourceDir, className.replace('.', File.separatorChar) + ".java");
              OutputStream output = new FileOutputStream(javaFilename);
              jcg.printSourceCode(className, output);
              output.close();
              javaFileList.add(javaFilename);
          }
          
          // then compile into .classes
          CodeGenUtil.externalCompile(javaFileList, classDir, null, false,
                  CodeGenUtil.DEFAULT_COMPILER, CodeGenUtil.DEFAULT_MEM_START, CodeGenUtil.DEFAULT_MEM_MAX, false, false);
          
          // then also dump the schema binary files into the JAR
          SchemaToJavaInput sourceSet = sources.getSchemaSourceSet();
          sourceSet.compileSchemaToBinaries(classDir);
          
          // then create the binding-config.xml file
          BindingFileGenerator bfg = sources.getBindingFileGenerator();
          OutputStream output = new FileOutputStream(ensureDir(classDir, PathBindingLoader.STANDARD_PATH));
          bfg.printBindingFile(output);
          output.close();
          
          // and jar it up to the target JAR
          CodeGenUtil.externalJar(classDir, params.getOutputJar());
          
          // delete temporary dirs
          tryToDelete(tempDir);
      }
      
      protected static File ensureDir(File rootdir, String filepath)
      {
          File result = new File(rootdir, filepath);
          File newdir = result.getParentFile();
          boolean created = (newdir.exists() && newdir.isDirectory()) || newdir.mkdirs();
          assert(created) : "Could not create " + newdir.getAbsolutePath();
          return result;
      }
      
      protected static File createDir(File rootdir, String subdir)
      {
          File newdir = (subdir == null) ? rootdir : new File(rootdir, subdir);
          boolean created = (newdir.exists() && newdir.isDirectory()) || newdir.mkdirs();
          assert(created) : "Could not create " + newdir.getAbsolutePath();
          return newdir;
      }
  
      protected static File createTempDir() throws IOException
      {
          File tmpFile = File.createTempFile("xbean", null);
          String path = tmpFile.getAbsolutePath();
          if (!path.endsWith(".tmp"))
              throw new IOException("Error: createTempFile did not create a file ending with .tmp");
          path = path.substring(0, path.length() - 4);
          File tmpSrcDir = null;
  
          for (int count = 0; count < 100; count++)
          {
              String name = path + ".d" + (count == 0 ? "" : Integer.toString(count++));
  
              tmpSrcDir = new File(name);
  
              if (!tmpSrcDir.exists())
              {
                  boolean created = tmpSrcDir.mkdirs();
                  assert created : "Could not create " + tmpSrcDir.getAbsolutePath();
                  break;
              }
          }
          tmpFile.deleteOnExit();
  
          return tmpSrcDir;
      }
  
      private static void tryToDelete(File dir)
      {
          if (dir.exists())
          {
              if (dir.isDirectory())
              {
                  String[] list = dir.list();
                  for (int i = 0; i < list.length; i++)
                      tryToDelete(new File(dir, list[i]));
              }
              if (!dir.delete())
                  return; // don't try very hard, because we're just deleting tmp
          }
      }
      
      
  }
  
  
  
  1.1                  xml-xmlbeans/v2/src/binding/org/apache/xmlbeans/impl/binding/compile/SimpleTylarLoader.java
  
  Index: SimpleTylarLoader.java
  ===================================================================
  /*
  * The Apache Software License, Version 1.1
  *
  *
  * Copyright (c) 2003 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
  *
  * 1. Redistributions of source code must retain the above copyright
  *    notice, this list of conditions and the following disclaimer.
  *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
  *
  * 3. The end-user documentation included with the redistribution,
  *    if any, must include the following acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
  *
  * 4. The names "Apache" and "Apache Software Foundation" must
  *    not be used to endorse or promote products derived from this
  *    software without prior written permission. For written
  *    permission, please contact apache@apache.org.
  *
  * 5. Products derived from this software may not be called "Apache
  *    XMLBeans", nor may "Apache" appear in their name, without prior
  *    written permission of the Apache Software Foundation.
  *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * ====================================================================
  *
  * This software consists of voluntary contributions made by many
  * individuals on behalf of the Apache Software Foundation and was
  * originally based on software copyright (c) 2003 BEA Systems
  * Inc., <http://www.bea.com/>. For more information on the Apache Software
  * Foundation, please see <http://www.apache.org/>.
  */
  
  package org.apache.xmlbeans.impl.binding.compile;
  
  import org.apache.xmlbeans.impl.binding.bts.BindingLoader;
  import org.apache.xmlbeans.impl.binding.bts.PathBindingLoader;
  import org.apache.xmlbeans.impl.binding.bts.BuiltinBindingLoader;
  import org.apache.xmlbeans.impl.jam.JClassLoader;
  import org.apache.xmlbeans.impl.schema.SchemaTypeLoaderImpl;
  import org.apache.xmlbeans.impl.schema.PathResourceLoader;
  import org.apache.xmlbeans.SchemaTypeLoader;
  import org.apache.xmlbeans.XmlBeans;
  
  import java.io.File;
  
  public class SimpleTylarLoader implements TylarLoader
  {
      private BindingLoader bindingLoader;
      private SchemaTypeLoader schemaTypeLoader;
      private JClassLoader jClassLoader;
  
      public SimpleTylarLoader(BindingLoader bindingLoader, JClassLoader jClassLoader, SchemaTypeLoader schemaTypeLoader)
      {
          this.bindingLoader = bindingLoader;
          this.schemaTypeLoader = schemaTypeLoader;
          this.jClassLoader = jClassLoader;
      }
  
      public BindingLoader getBindingLoader()
      {
          return this.bindingLoader;
      }
  
      public JClassLoader getJClassLoader()
      {
          return this.jClassLoader;
      }
  
      public SchemaTypeLoader getSchemaTypeLoader()
      {
          return this.schemaTypeLoader;
      }
              
              
      public static TylarLoader forClassLoader(ClassLoader loader)
      {
          BindingLoader bindingLoader = PathBindingLoader.forClassLoader(loader);
          JClassLoader jClassLoader = null; // todo by pcal
          SchemaTypeLoader sTypeLoader = XmlBeans.typeLoaderForClassLoader(loader);
          
          return new SimpleTylarLoader(bindingLoader, jClassLoader, sTypeLoader);
      }
      
      public static TylarLoader forClassPath(File[] classpath)
      {
          BindingLoader bindingLoader = PathBindingLoader.forClasspath(classpath);
          JClassLoader jClassLoader = null; // todo by pcal
          SchemaTypeLoader sTypeLoader = SchemaTypeLoaderImpl.build(null, new PathResourceLoader(classpath), null);
          
          return new SimpleTylarLoader(bindingLoader, jClassLoader, sTypeLoader);
      }
      
      public static TylarLoader forBuiltins()
      {
          BindingLoader bindingLoader = BuiltinBindingLoader.getInstance();
          JClassLoader jClassLoader = null; // todo by pcal
          SchemaTypeLoader sTypeLoader = XmlBeans.getBuiltinTypeSystem();
          
          return new SimpleTylarLoader(bindingLoader, jClassLoader, sTypeLoader);
      }
  }
  
  
  
  1.8       +1 -1      xml-xmlbeans/v2/src/configschema/schema/binding-config.xsd
  
  Index: binding-config.xsd
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/configschema/schema/binding-config.xsd,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- binding-config.xsd	31 Oct 2003 21:07:33 -0000	1.7
  +++ binding-config.xsd	3 Nov 2003 21:58:52 -0000	1.8
  @@ -58,7 +58,7 @@
       <xs:complexContent>
         <xs:extension base="tns:binding-type">
           <xs:sequence>
  -          <xs:element name="element-name" type="xs:NCName"/>
  +          <xs:element name="type-of-element" type="tns:xml-signature"/>
           </xs:sequence>
         </xs:extension>
       </xs:complexContent>
  
  
  
  1.2       +1 -1      xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaPropertyImpl.java
  
  Index: SchemaPropertyImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaPropertyImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SchemaPropertyImpl.java	26 Sep 2003 21:23:28 -0000	1.1
  +++ SchemaPropertyImpl.java	3 Nov 2003 21:58:52 -0000	1.2
  @@ -136,7 +136,7 @@
           { mutate(); _typeref = typeref; }
   
       public SchemaType javaBasedOnType()
  -        { return _javaBasedOnTypeRef.get(); }
  +        { return _javaBasedOnTypeRef == null ? null : _javaBasedOnTypeRef.get(); }
   
       public boolean extendsJavaSingleton()
           { return _extendsSingleton; }
  
  
  
  1.8       +17 -11    xml-xmlbeans/v2/test/src/drt/drtcases/BindingTests.java
  
  Index: BindingTests.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/drt/drtcases/BindingTests.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- BindingTests.java	29 Oct 2003 20:32:03 -0000	1.7
  +++ BindingTests.java	3 Nov 2003 21:58:52 -0000	1.8
  @@ -23,11 +23,11 @@
   import org.apache.xmlbeans.impl.binding.compile.JAXRPCSchemaBinder;
   import org.apache.xmlbeans.impl.binding.compile.SchemaToJavaResult;
   import org.apache.xmlbeans.impl.binding.compile.JavaCodeGenerator;
  +import org.apache.xmlbeans.impl.binding.compile.SchemaToJavaInput;
  +import org.apache.xmlbeans.impl.binding.compile.SimpleSchemaSourceSet;
  +import org.apache.xmlbeans.impl.binding.compile.SimpleSchemaToJavaResultCompiler;
  +import org.apache.xmlbeans.impl.binding.compile.TylarLoader;
   import org.apache.xmlbeans.x2003.x09.bindingConfig.BindingConfigDocument;
  -import org.apache.xmlbeans.XmlBeans;
  -import org.apache.xmlbeans.XmlObject;
  -import org.apache.xmlbeans.SchemaTypeSystem;
  -import org.w3.x2001.xmlSchema.SchemaDocument;
   
   import javax.xml.namespace.QName;
   import java.io.File;
  @@ -42,17 +42,17 @@
       
       public void testJAXRPCBinding() throws Exception
       {
  +        // bind
           File typesonlyfile = TestEnv.xbeanCase("schema/typesonly/typesonly.xsd");
  -        SchemaTypeSystem sts = XmlBeans.compileXsd(new XmlObject[] { SchemaDocument.Factory.parse(typesonlyfile) }, XmlBeans.getBuiltinTypeSystem(), null);
  -        SchemaToJavaResult result = JAXRPCSchemaBinder.bind(sts, BuiltinBindingLoader.getInstance());
  +        SchemaToJavaInput input = SimpleSchemaSourceSet.forFile(typesonlyfile);
  +        SchemaToJavaResult result = JAXRPCSchemaBinder.bind(input);
           if (verbose)
  -            result.getBindingFileGenerator().printBindingFile(System.out);
  -        JavaCodeGenerator javacode = result.getJavaCodeGenerator();
  -        for (Iterator i = javacode.getToplevelClasses().iterator(); i.hasNext(); )
           {
  -            String javaclass = (String)i.next();
  -            if (verbose)
  +            result.getBindingFileGenerator().printBindingFile(System.out);
  +            JavaCodeGenerator javacode = result.getJavaCodeGenerator();
  +            for (Iterator i = javacode.getToplevelClasses().iterator(); i.hasNext(); )
               {
  +                String javaclass = (String)i.next();
                   System.out.println("=======================");
                   System.out.println(javaclass);
                   System.out.println("=======================");
  @@ -60,6 +60,12 @@
                   System.out.flush();
               }
           }
  +        
  +        // now compile
  +        SimpleSchemaToJavaResultCompiler.Params params = new SimpleSchemaToJavaResultCompiler.Params();
  +        File theJar = TestEnv.xbeanOutput("schema/binding/typesonly.jar");
  +        params.setOutputJar(theJar);
  +        SimpleSchemaToJavaResultCompiler.compile(result, params);
       }
   
       public void testBindingFile() throws Exception
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org