You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by ce...@apache.org on 2003/12/16 23:00:50 UTC

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

cezar       2003/12/16 14:00:50

  Modified:    v2       build.xml
               v2/bin   scomp scomp.cmd
               v2/src/common/org/apache/xmlbeans/impl/common IOUtil.java
               v2/src/typeimpl/org/apache/xmlbeans/impl/schema
                        SchemaTypeSystemCompiler.java
                        SchemaTypeSystemImpl.java StscImporter.java
                        StscState.java
               v2/src/xmlcomp/org/apache/xmlbeans/impl/tool
                        SchemaCodeGenerator.java SchemaCompiler.java
                        XMLBean.java
               v2/src/xmlstore/org/apache/xmlbeans/impl/store Root.java
               v2/test/src/drt/drtcases NumeralsTests.java
                        RichParserTests.java
  Added:       v2/src/common/org/apache/xmlbeans/impl/common
                        ResolverUtil.java
               v2/test/cases/xmlcatalog MOVEDincluded.xsd cat.xml
                        includer1.xsd includer2.xsd
  Log:
  Added support for XML Catalog, based on Apache Commons CatalogResolver.
  
  How it works:
  
  1) there is a global read only resolver that can be set through "xmlbean.entityResolver" system property
  2) option 1 is overwritten if:
    2a) - the switch "-catalog [file]" is used on the command line for scomp
    2b) - or a resolver is set in XmlOptions (XmlOptions.setEntityResolver() )
  
  CR: David Bau
  DRT: passing
  
  Revision  Changes    Path
  1.26      +50 -1     xml-xmlbeans/v2/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/build.xml,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- build.xml	16 Dec 2003 05:59:47 -0000	1.25
  +++ build.xml	16 Dec 2003 22:00:50 -0000	1.26
  @@ -77,6 +77,37 @@
            verbose="true" usetimestamp="true" ignoreerrors="true"/>
     </target>
   
  +    <!-- get resolver.jar -->
  +    <target name="check.xcresolver.zip">
  +      <condition property="xcresolver.zip.exists">
  +          <available file="build/lib/xcresolver.zip"/>
  +      </condition>
  +    </target>
  +
  +    <target name="xcresolver.zip" depends="check.xcresolver.zip, dirs" unless="xcresolver.zip.exists">
  +      <get dest="build/lib/xcresolver.zip"
  +           src="http://www.apache.org/dist/xml/commons/binaries/xml-commons-resolver-1.1.zip"
  +           verbose="true" usetimestamp="true" ignoreerrors="true"/>
  +    </target>
  +
  +    <target name="check.resolver.jar">
  +      <condition property="resolver.jar.exists">
  +          <available file="build/lib/resolver.jar"/>
  +      </condition>
  +    </target>
  +
  +    <target name="resolver.jar" depends="xcresolver.zip, check.resolver.jar" unless="resolver.jar.exists">
  +      <unzip src="build/lib/xcresolver.zip" dest="build/lib/">
  +        <patternset>
  +          <include name="*/resolver.jar"/>
  +      </patternset>
  +      </unzip>
  +      <move file="build/lib/xml-commons-resolver-1.1/resolver.jar" tofile="build/lib/resolver.jar"/>
  +      <delete dir="build/lib/xml-commons-resolver-1.1" />
  +      <delete file="build/lib/xcresolver.zip" />
  +    </target>
  +
  +
     <target name="xbean" depends="xbean.jar">
       <copy file="build/lib/xbean.jar" tofile="build/ar/xbean.jar"/>
     </target>
  @@ -132,8 +163,26 @@
         <formatter type="plain"/>
         <test name="drtcases.SmokeTests" outfile="build/test/output/drt-product" />
       </junit>
  +    <!-- Disabled, to enable update catalog test/cases/xmlcatalog/cat.xml
  +    <antcall target="xmlcatalogTest" /-->
     </target>
   
  +    <path id="xmlcatalogTest.run.path">
  +      <pathelement location="build/lib/xbean.jar"/>
  +      <pathelement location="build/lib/jsr173_api.jar"/>
  +      <pathelement location="build/lib/resolver.jar"/>
  +    </path>
  +
  +  <target name="xmlcatalogTest">
  +    <echo message="___ XML Catalog Test ___" />
  +    <java classname="${schema_compiler}" classpathref="xmlcatalogTest.run.path" fork="true" failonerror="true">
  +        <jvmarg value="-ea"/>
  +        <arg line="-catalog test/cases/xmlcatalog/cat.xml -out build/private/lib/xmlcatalogTest.jar test/cases/xmlcatalog/includer1.xsd"/>
  +    </java>
  +    <echo message="___ XML Catalog Test :    PASSED" />
  +  </target>
  +
  +
     <target name="builddrt" depends="drt.jar, random.jar, eric"/>
   
     <target name="eric" depends="erictest.jar"/>
  @@ -563,7 +612,7 @@
                    common.classes, typeimpl.classes, xmlcomp.classes,
                    xmlstore.classes, binding.classes, marshal.classes,
                    oldxbean.jar, xsdschema.classes,
  -                 xmlinputstream.classes">
  +                 xmlinputstream.classes, resolver.jar">
       <jar jarfile="build/lib/xbean.jar" index="true">
         <fileset dir="build/classes/xmlpublic"/>
         <fileset dir="build/classes/typestore"/>
  
  
  
  1.3       +1 -1      xml-xmlbeans/v2/bin/scomp
  
  Index: scomp
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/bin/scomp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- scomp	13 Nov 2003 01:03:00 -0000	1.2
  +++ scomp	16 Dec 2003 22:00:50 -0000	1.3
  @@ -4,6 +4,6 @@
   #Builds XBean types from xsd files.
   
   cp=
  -    cp=$cp:$XMLBEANS_HOME/build/ar/xbean.jar:$XMLBEANS_HOME/build/lib/jsr173_07_api.jar
  +    cp=$cp:$XMLBEANS_HOME/build/ar/xbean.jar:$XMLBEANS_HOME/build/lib/jsr173_07_api.jar:$XMLBEANS_HOME/build/lib/resolver.jar
   
   java -classpath $cp org.apache.xmlbeans.impl.tool.SchemaCompiler $*
  
  
  
  1.4       +1 -0      xml-xmlbeans/v2/bin/scomp.cmd
  
  Index: scomp.cmd
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/bin/scomp.cmd,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- scomp.cmd	15 Nov 2003 15:16:23 -0000	1.3
  +++ scomp.cmd	16 Dec 2003 22:00:50 -0000	1.4
  @@ -10,6 +10,7 @@
   set cp=
   set cp=%cp%;%XMLBEANS_HOME%\build\ar\xbean.jar
   set cp=%cp%;%XMLBEANS_HOME%\build\lib\jsr173_api.jar
  +set cp=%cp%;%XMLBEANS_HOME%\build\lib\resolver.jar
   
   java -classpath %cp% org.apache.xmlbeans.impl.tool.SchemaCompiler %*
   
  
  
  
  1.2       +27 -0     xml-xmlbeans/v2/src/common/org/apache/xmlbeans/impl/common/IOUtil.java
  
  Index: IOUtil.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/common/org/apache/xmlbeans/impl/common/IOUtil.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IOUtil.java	26 Sep 2003 21:23:26 -0000	1.1
  +++ IOUtil.java	16 Dec 2003 22:00:50 -0000	1.2
  @@ -62,6 +62,10 @@
   import java.io.File;
   import java.io.FileInputStream;
   import java.io.FileOutputStream;
  +import java.io.Writer;
  +import java.io.Reader;
  +import java.io.FileWriter;
  +import java.io.FileReader;
   import java.net.URI;
   import java.nio.channels.FileChannel;
   
  @@ -102,6 +106,22 @@
           try { output.close(); } catch (IOException ignore) {}
       }
   
  +    public static void copyCompletely(Reader input, Writer output)
  +        throws IOException
  +    {
  +        char[] buf = new char[8192];
  +        while (true)
  +        {
  +            int length = input.read(buf);
  +            if (length < 0)
  +                break;
  +            output.write(buf, 0, length);
  +        }
  +
  +        try { input.close(); } catch (IOException ignore) {}
  +        try { output.close(); } catch (IOException ignore) {}
  +    }
  +
       public static void copyCompletely(URI input, URI output)
           throws IOException
       {
  @@ -132,4 +152,11 @@
           }
       }
   
  +    public 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;
  +    }
   }
  
  
  
  1.1                  xml-xmlbeans/v2/src/common/org/apache/xmlbeans/impl/common/ResolverUtil.java
  
  Index: ResolverUtil.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) 2000-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.common;
  
  import org.xml.sax.EntityResolver;
  import java.lang.reflect.Constructor;
  import java.lang.reflect.Method;
  
  /**
   * Author: Cezar Andrei (cezar.andrei at bea.com)
   * Date: Dec 3, 2003
   */
  public class ResolverUtil
  {
      private static EntityResolver _entityResolver = null;
  
      static
      {
          try
          {
              Object o = Class.forName(System.getProperty("xmlbean.entityResolver")).newInstance();
              _entityResolver = (EntityResolver)o;
          }
          catch (Exception e)
          {
              _entityResolver = null;
          }
      }
  
      public static EntityResolver getGlobalEntityResolver()
      {
          return _entityResolver;
      }
  
      public static EntityResolver resolverForCatalog(String catalogFile)
      {
          if (catalogFile==null)
              return null;
  
          try
          {
              Class cmClass = Class.forName("org.apache.xml.resolver.CatalogManager");
              Constructor cstrCm = cmClass.getConstructor(new Class[] {});
              Object cmObj = cstrCm.newInstance(new Object[] {});
              Method cmMethod = cmClass.getMethod("setCatalogFiles", new Class[] {String.class});
              cmMethod.invoke(cmObj, new String[] {catalogFile});
  
              Class crClass = Class.forName("org.apache.xml.resolver.tools.CatalogResolver");
              Constructor cstrCr = crClass.getConstructor(new Class[] {cmClass});
              Object crObj = cstrCr.newInstance(new Object[] {cmObj});
  
              return (EntityResolver)crObj;
          }
          catch( Exception e )
          {
              return null;
          }
      }
  }
  
  
  
  1.2       +17 -4     xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java
  
  Index: SchemaTypeSystemCompiler.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemCompiler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SchemaTypeSystemCompiler.java	26 Sep 2003 21:23:28 -0000	1.1
  +++ SchemaTypeSystemCompiler.java	16 Dec 2003 22:00:50 -0000	1.2
  @@ -74,6 +74,7 @@
   import org.apache.xmlbeans.impl.config.SchemaConfig;
   
   import java.util.Collection;
  +import java.io.File;
   
   public class SchemaTypeSystemCompiler
   {
  @@ -88,6 +89,7 @@
           private boolean javaize;
           private URI baseURI;
           private Map sourcesToCopyMap;
  +        private File schemasDir;
   
           public String getName()
           {
  @@ -178,16 +180,26 @@
           {
               this.sourcesToCopyMap = sourcesToCopyMap;
           }
  +
  +        public File getSchemasDir()
  +        {
  +            return schemasDir;
  +        }
  +
  +        public void setSchemasDir(File schemasDir)
  +        {
  +            this.schemasDir = schemasDir;
  +        }
       }
   
       public static SchemaTypeSystem compile(Parameters params)
       {
  -        return compileImpl(params.getName(), params.getSchemas(), params.getConfigs(), params.getLinkTo(), params.getOptions(), params.getErrorListener(), params.isJavaize(), params.getBaseURI(), params.getSourcesToCopyMap());
  +        return compileImpl(params.getName(), params.getSchemas(), params.getConfigs(), params.getLinkTo(), params.getOptions(), params.getErrorListener(), params.isJavaize(), params.getBaseURI(), params.getSourcesToCopyMap(), params.getSchemasDir());
       }
       
  -    /* package!!! */ static SchemaTypeSystemImpl compileImpl(
  -        String name, Schema[] schemas, Config[] configs,
  -        SchemaTypeLoader linkTo, XmlOptions options, Collection outsideErrors, boolean javaize, URI baseURI, Map sourcesToCopyMap)
  +    /* package!!! */ static SchemaTypeSystemImpl compileImpl( String name, Schema[] schemas,
  +         Config[] configs, SchemaTypeLoader linkTo, XmlOptions options, Collection outsideErrors,
  +         boolean javaize, URI baseURI, Map sourcesToCopyMap, File schemasDir)
       {
           if (linkTo == null)
               throw new IllegalArgumentException("Must supply linkTo");
  @@ -203,6 +215,7 @@
               state.setSchemaConfig(SchemaConfig.forConfigDocuments(configs));
               state.setOptions(options);
               state.setGivenTypeSystemName(name);
  +            state.setSchemasDir(schemasDir);
               if (baseURI != null)
                   state.setBaseUri(baseURI);
   
  
  
  
  1.3       +1 -1      xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java
  
  Index: SchemaTypeSystemImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/SchemaTypeSystemImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SchemaTypeSystemImpl.java	13 Nov 2003 01:03:00 -0000	1.2
  +++ SchemaTypeSystemImpl.java	16 Dec 2003 22:00:50 -0000	1.3
  @@ -229,7 +229,7 @@
           SchemaTypeSystemImpl stsi =
               SchemaTypeSystemCompiler.compileImpl(
                   null, (Schema[])schemas.toArray(EMPTY_SCHEMA_ARRAY),
  -                (Config[])configs.toArray(EMPTY_CONFIG_ARRAY), linkTo, options, errorWatcher, false, null, null);
  +                (Config[])configs.toArray(EMPTY_CONFIG_ARRAY), linkTo, options, errorWatcher, false, null, null, null);
   
           if (errorWatcher.hasError())
           {
  
  
  
  1.2       +147 -8    xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/StscImporter.java
  
  Index: StscImporter.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/StscImporter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StscImporter.java	26 Sep 2003 21:23:28 -0000	1.1
  +++ StscImporter.java	16 Dec 2003 22:00:50 -0000	1.2
  @@ -78,18 +78,27 @@
   import java.io.IOException;
   import java.io.Reader;
   import java.io.InputStream;
  +import java.io.File;
  +import java.io.FileOutputStream;
  +import java.io.ByteArrayInputStream;
  +import java.io.ByteArrayOutputStream;
  +import java.io.CharArrayReader;
  +import java.io.FileWriter;
  +import java.io.Writer;
  +import java.io.CharArrayWriter;
  +import java.io.OutputStreamWriter;
   
   import org.apache.xmlbeans.XmlObject;
   import org.apache.xmlbeans.XmlException;
   import org.apache.xmlbeans.XmlOptions;
   import org.apache.xmlbeans.SchemaTypeLoader;
   import org.apache.xmlbeans.impl.common.XmlErrorContext;
  +import org.apache.xmlbeans.impl.common.IOUtil;
  +import org.apache.xmlbeans.impl.common.XmlEncodingSniffer;
   import org.xml.sax.EntityResolver;
   import org.xml.sax.InputSource;
   import org.xml.sax.SAXException;
   
  -import javax.xml.transform.Source;
  -
   public class StscImporter
   {
       public static SchemaToProcess[] resolveImportsAndIncludes(Schema[] startWith)
  @@ -457,16 +466,21 @@
                   try
                   {
                       source = resolver.resolveEntity(namespace, absoluteURL);
  -                }
  +                    if (source==null)
  +                         throw new XmlException("Unresolvable entity for: " + namespace + " : " + absoluteURL);
  +                }   // TODO (cezar)add check source==null
                   catch (SAXException e)
                   {
                       throw new XmlException(e);
                   }
                       
  +                state.addSourceUri(absoluteURL, null);
  +
                   // first preference for InputSource contract: character stream
                   Reader reader = source.getCharacterStream();
                   if (reader != null)
                   {
  +                    reader = copySchemaSource(absoluteURL, reader, state);
                       XmlOptions options = new XmlOptions();
                       options.setLoadLineNumbers();
                       options.setDocumentSourceName(absoluteURL);
  @@ -477,6 +491,7 @@
                   InputStream bytes = source.getByteStream();
                   if (bytes != null)
                   {
  +                    bytes = copySchemaSource(absoluteURL, bytes, state);
                       String encoding = source.getEncoding();
                       XmlOptions options = new XmlOptions();
                       options.setLoadLineNumbers();
  @@ -491,6 +506,8 @@
                   String urlToLoad = source.getSystemId();
                   if (urlToLoad == null)
                       throw new IOException("EntityResolver unable to resolve " + absoluteURL + " (for namespace " + namespace + ")");
  +
  +                copySchemaSource(absoluteURL, state);
                   XmlOptions options = new XmlOptions();
                   options.setLoadLineNumbers();
                   options.setLoadMessageDigest();
  @@ -498,13 +515,16 @@
                   URL urlDownload = new URL(urlToLoad);
                   return loader.parse(urlDownload, null, options);
               }
  -            
  +
               // no resolver - just use the URL directly, no substitution
  +            state.addSourceUri(absoluteURL, null);
  +            copySchemaSource(absoluteURL, state);
  +
               XmlOptions options = new XmlOptions();
               options.setLoadLineNumbers();
               options.setLoadMessageDigest();
  -                
               URL urlDownload = new URL(absoluteURL);
  +
               return loader.parse(urlDownload, null, options);
           }
   
  @@ -646,9 +666,11 @@
                   while (hasNextToScan())
                   {
                       SchemaToProcess stp = nextToScan();
  -                    state.addSourceUri(stp.getSourceName(), null);
  +                    String uri = stp.getSourceName();
  +                    state.addSourceUri(uri, null);
                       result.add(stp);
  -                    
  +                    copySchemaSource(uri, state);
  +
                       {
                           // handle imports
                           Import[] imports = stp.getSchema().getImportArray();
  @@ -743,6 +765,123 @@
   
               return (SchemaToProcess[])result.toArray(new SchemaToProcess[result.size()]);
           }
  -    }
   
  +        private static Reader copySchemaSource(String url, Reader reader, StscState state)
  +        {
  +            //Copy the schema file if it wasn't already copied
  +            if (state.getSchemasDir() == null)
  +                return reader;
  +
  +            String schemalocation = state.sourceNameForUri(url);
  +            File targetFile = new File(state.getSchemasDir(), schemalocation);
  +            if (targetFile.exists())
  +                return reader;
  +
  +            try
  +            {
  +                File parentDir = new File(targetFile.getParent());
  +                IOUtil.createDir(parentDir, null);
  +
  +                CharArrayReader car = copy(reader);
  +                XmlEncodingSniffer xes = new XmlEncodingSniffer(car, null);
  +                Writer out = new OutputStreamWriter(new FileOutputStream(targetFile), xes.getXmlEncoding());
  +                IOUtil.copyCompletely(car, out);
  +
  +                car.reset();
  +                return car;
  +            }
  +            catch (IOException e)
  +            {
  +                System.err.println("IO Error " + e);
  +                return reader;
  +            }
  +        }
  +
  +        private static InputStream copySchemaSource(String url, InputStream bytes, StscState state)
  +        {
  +            //Copy the schema file if it wasn't already copied
  +            if (state.getSchemasDir() == null)
  +                return bytes;
  +
  +            String schemalocation = state.sourceNameForUri(url);
  +            File targetFile = new File(state.getSchemasDir(), schemalocation);
  +            if (targetFile.exists())
  +                return bytes;
  +
  +            try
  +            {
  +                File parentDir = new File(targetFile.getParent());
  +                IOUtil.createDir(parentDir, null);
  +
  +                ByteArrayInputStream bais = copy(bytes);
  +
  +                FileOutputStream out = new FileOutputStream(targetFile);
  +                IOUtil.copyCompletely(bais, out);
  +
  +                bais.reset();
  +                return bais;
  +            }
  +            catch (IOException e)
  +            {
  +                System.err.println("IO Error " + e);
  +                return bytes;
  +            }
  +        }
  +
  +        private static void copySchemaSource(String urlLoc, StscState state)
  +        {
  +            //Copy the schema file if it wasn't already copied
  +            if (state.getSchemasDir()!=null)
  +            {
  +                String schemalocation = state.sourceNameForUri(urlLoc);
  +
  +                File targetFile = new File(state.getSchemasDir(), schemalocation);
  +                if (!targetFile.exists())
  +                {
  +                    try
  +                    {
  +                        File parentDir = new File(targetFile.getParent());
  +                        IOUtil.createDir(parentDir, null);
  +
  +                        InputStream in = null;
  +                        URL url = new URL(urlLoc);
  +                        // Copy the file from filepath to schema/src/<schemaFile>
  +                        in = url.openStream();
  +
  +                        FileOutputStream out = new FileOutputStream(targetFile);
  +                        IOUtil.copyCompletely(in, out);
  +                    }
  +                    catch (IOException e)
  +                    {
  +                        System.err.println("IO Error " + e);
  +                        // failure = true; - not cause for failure
  +                    }
  +                }
  +            }
  +        }
  +
  +        private static ByteArrayInputStream copy(InputStream is) throws IOException
  +        {
  +            byte [] buf = new byte[1024];
  +            ByteArrayOutputStream baos = new ByteArrayOutputStream();
  +
  +            int bytesRead;
  +            while(( bytesRead = is.read(buf, 0, 1024)) > 0)
  +                baos.write(buf, 0, bytesRead);
  +
  +            return new ByteArrayInputStream(baos.toByteArray());
  +        }
  +
  +        private static CharArrayReader copy(Reader is) throws IOException
  +        {
  +            char[] buf = new char[1024];
  +            CharArrayWriter baos = new CharArrayWriter();
  +
  +            int bytesRead;
  +            while(( bytesRead = is.read(buf, 0, 1024)) > 0)
  +                baos.write(buf, 0, bytesRead);
  +
  +            return new CharArrayReader(baos.toCharArray());
  +        }
  +    }
   }
  
  
  
  1.3       +16 -0     xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/StscState.java
  
  Index: StscState.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/typeimpl/org/apache/xmlbeans/impl/schema/StscState.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StscState.java	13 Nov 2003 01:03:00 -0000	1.2
  +++ StscState.java	16 Dec 2003 22:00:50 -0000	1.3
  @@ -58,6 +58,7 @@
   
   import org.apache.xmlbeans.impl.common.XmlErrorContext;
   import org.apache.xmlbeans.impl.common.QNameHelper;
  +import org.apache.xmlbeans.impl.common.ResolverUtil;
   import org.apache.xmlbeans.impl.config.SchemaConfig;
   import org.apache.xmlbeans.XmlObject;
   import org.apache.xmlbeans.SchemaGlobalElement;
  @@ -124,6 +125,7 @@
       private boolean _noAnn;
       private Set _mdefNamespaces     = buildDefaultMdefNamespaces();
       private EntityResolver _entityResolver;
  +    private File _schemasDir;
   
       private static Set buildDefaultMdefNamespaces()
       {
  @@ -314,6 +316,10 @@
           _doingDownloads = options.hasOption(XmlOptions.COMPILE_DOWNLOAD_URLS) ? true :
                   "true".equals(System.getProperty("xmlbean.downloadurls", "false"));
           _entityResolver = (EntityResolver)options.get(XmlOptions.ENTITY_RESOLVER);
  +
  +        if (_entityResolver == null)
  +            _entityResolver = ResolverUtil.getGlobalEntityResolver();
  +
           if (_entityResolver != null)
               _doingDownloads = true;
           
  @@ -1123,4 +1129,14 @@
       Map _sourceForUri = new HashMap();
       URI _baseURI = URI.create(PROJECT_URL_PREFIX + "/");
       SchemaTypeLoader _s4sloader = XmlBeans.typeLoaderForClassLoader(SchemaDocument.class.getClassLoader());
  +
  +    public File getSchemasDir()
  +    {
  +        return _schemasDir;
  +    }
  +
  +    public void setSchemasDir(File _schemasDir)
  +    {
  +        this._schemasDir = _schemasDir;
  +    }
   }
  
  
  
  1.2       +53 -49    xml-xmlbeans/v2/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCodeGenerator.java
  
  Index: SchemaCodeGenerator.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCodeGenerator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SchemaCodeGenerator.java	26 Sep 2003 21:23:33 -0000	1.1
  +++ SchemaCodeGenerator.java	16 Dec 2003 22:00:50 -0000	1.2
  @@ -56,26 +56,35 @@
   
   package org.apache.xmlbeans.impl.tool;
   
  -import org.apache.xmlbeans.SchemaTypeSystem;
   import org.apache.xmlbeans.SchemaType;
  +import org.apache.xmlbeans.SchemaTypeSystem;
   import org.apache.xmlbeans.impl.common.XmlErrorWatcher;
  -
  -import java.io.*;
  -import java.util.*;
  -import java.net.URL;
  -import java.lang.reflect.Method;
  -import java.lang.reflect.InvocationTargetException;
  -
   import org.apache.xmlbeans.impl.schema.SchemaTypeCodePrinter;
  -import org.apache.xmlbeans.impl.common.IOUtil;
  -
   import repackage.Repackager;
   
  +import java.io.File;
  +import java.io.FileWriter;
  +import java.io.IOException;
  +import java.io.StringWriter;
  +import java.io.Writer;
  +import java.lang.reflect.InvocationTargetException;
  +import java.lang.reflect.Method;
  +import java.util.ArrayList;
  +import java.util.Arrays;
  +import java.util.HashSet;
  +import java.util.Iterator;
  +import java.util.List;
  +import java.util.Map;
  +import java.util.Set;
  +
   public class SchemaCodeGenerator
   {
       // input directory, output dir filename
       // todo: output jar
  -    public static boolean compileTypeSystem(SchemaTypeSystem saver, File sourcedir, File[] javasrc, Map sourcesToCopyMap, File[] classpath, File classesdir, File outputJar, boolean nojavac, boolean jaxb, XmlErrorWatcher errors, String repackage, boolean verbose, List sourcefiles )
  +    public static boolean compileTypeSystem(SchemaTypeSystem saver, File sourcedir, File[] javasrc,
  +         Map sourcesToCopyMap, File[] classpath, File classesdir, File outputJar, boolean nojavac,
  +         boolean jaxb, XmlErrorWatcher errors, String repackage, boolean verbose, List sourcefiles,
  +         File schemasDir)
       {
   
           if (sourcedir == null || classesdir == null)
  @@ -85,36 +94,39 @@
   
           saver.saveToDirectory(classesdir);
   
  -        // Save the schema sources to the classes directory
  -        if ((sourcesToCopyMap != null) && (sourcesToCopyMap.size() > 0))
  -        {
  -            File schemasdir = createDir(classesdir, "schema/src");
  -
  -            for (Iterator iter = sourcesToCopyMap.keySet().iterator(); iter.hasNext();)
  -            {
  -                String key = (String)iter.next();
  -
  -                try
  -                {
  -                    URL url = new URL(key);
  -                    String schemalocation = (String)sourcesToCopyMap.get(key);
  -
  -                    File targetFile = new File(schemasdir, schemalocation);
  -                    File parentDir = new File(targetFile.getParent());
  -                    createDir(parentDir, null);
  -
  -                    // Copy the file from filepath to schema/src/<schemaFile>
  -                    InputStream in = url.openStream();
  -                    FileOutputStream out = new FileOutputStream(new File(schemasdir, schemalocation));
  -                    IOUtil.copyCompletely(in, out);
  -                }
  -                catch (IOException e)
  -                {
  -                    System.err.println("IO Error " + e);
  -                    // failure = true; - not cause for failure
  -                }
  -            }
  -        }
  +        // Schema files already copyed when they where parsed
  +//        if ((sourcesToCopyMap != null) && (sourcesToCopyMap.size() > 0))
  +//        {
  +//            for (Iterator iter = sourcesToCopyMap.keySet().iterator(); iter.hasNext();)
  +//            {
  +//                String key = (String)iter.next();
  +//
  +//                try
  +//                {
  +//                    String schemalocation = (String)sourcesToCopyMap.get(key);
  +//
  +//                    File targetFile = new File(schemasDir, schemalocation);
  +//                    if (targetFile.exists())
  +//                        continue;
  +//
  +//                    File parentDir = new File(targetFile.getParent());
  +//                    IOUtil.createDir(parentDir, null);
  +//
  +//                    InputStream in = null;
  +//                    URL url = new URL(key);
  +//                    // Copy the file from filepath to schema/src/<schemaFile>
  +//                    in = url.openStream();
  +//
  +//                    FileOutputStream out = new FileOutputStream(targetFile);
  +//                    IOUtil.copyCompletely(in, out);
  +//                }
  +//                catch (IOException e)
  +//                {
  +//                    System.err.println("IO Error " + e);
  +//                    // failure = true; - not cause for failure
  +//                }
  +//            }
  +//        }
   
           Repackager repackager = repackage == null ? null : new Repackager( repackage );
   
  @@ -283,14 +295,6 @@
               e2.initCause(e);
               throw e2;
           }
  -    }
  -
  -    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
  
  
  
  1.3       +37 -6     xml-xmlbeans/v2/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java
  
  Index: SchemaCompiler.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlcomp/org/apache/xmlbeans/impl/tool/SchemaCompiler.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SchemaCompiler.java	13 Nov 2003 01:03:01 -0000	1.2
  +++ SchemaCompiler.java	16 Dec 2003 22:00:50 -0000	1.3
  @@ -64,6 +64,8 @@
   import org.apache.xmlbeans.impl.common.XmlErrorPrinter;
   import org.apache.xmlbeans.impl.common.XmlErrorWatcher;
   import org.apache.xmlbeans.impl.common.XmlErrorContext;
  +import org.apache.xmlbeans.impl.common.ResolverUtil;
  +import org.apache.xmlbeans.impl.common.IOUtil;
   import org.apache.xmlbeans.impl.values.XmlListImpl;
   import org.apache.xmlbeans.SchemaTypeSystem;
   import org.apache.xmlbeans.SchemaTypeLoader;
  @@ -79,6 +81,7 @@
   import java.net.URI;
   
   import org.w3.x2001.xmlSchema.SchemaDocument;
  +import org.xml.sax.EntityResolver;
   
   public class SchemaCompiler
   {
  @@ -107,6 +110,7 @@
               System.out.println("    -verbose - print more informational messages");
               System.out.println("    -license - prints license information");
               System.out.println("    -allowmdef \"[ns] [ns] [ns]\" - ignores multiple defs in given namespaces");
  +            System.out.println("    -catalog [file] -  catalog file for org.apache.xml.resolver.tools.CatalogResolver. (Note: needs resolver.jar from http://xml.apache.org/commons/components/resolver/index.html)");
               /* Undocumented feature - pass in one schema compiler extension and related parameters
               System.out.println("    -repackage - repackage specification");
               System.out.println("    -extension - registers a schema compiler extension");
  @@ -132,6 +136,7 @@
           opts.add("extension");
           opts.add("extensionParms");
           opts.add("allowmdef");
  +        opts.add("catalog");
           CommandLine cl = new CommandLine(args, opts);
   
           if (cl.getOpt("license") != null)
  @@ -236,9 +241,9 @@
               jarfile = new File(outputfilename);
   
           if (src == null)
  -            src = SchemaCodeGenerator.createDir(tempdir, "src");
  +            src = IOUtil.createDir(tempdir, "src");
           if (classes == null)
  -            classes = SchemaCodeGenerator.createDir(tempdir, "classes");
  +            classes = IOUtil.createDir(tempdir, "classes");
   
           File[] classpath = null;
           String cpString = cl.getOpt("cp");
  @@ -276,6 +281,8 @@
   
           XmlErrorPrinter err = new XmlErrorPrinter(verbose, baseURI);
   
  +        String catString = cl.getOpt("catalog");
  +
           Parameters params = new Parameters();
           params.setBaseDir(baseDir);
           params.setXsdFiles(xsdFiles);
  @@ -304,6 +311,7 @@
           params.setExtensions(extensions);
           params.setJaxb(jaxb);
           params.setMdefNamespaces(mdefNamespaces);
  +        params.setCatalogFile(catString);
   
           boolean result = compile(params);
   
  @@ -345,6 +353,7 @@
           private List extensions = Collections.EMPTY_LIST;
           private boolean jaxb;
           private Set mdefNamespaces = Collections.EMPTY_SET;
  +        private String catalogFile;
   
           public File getBaseDir()
           {
  @@ -615,6 +624,16 @@
               this.mdefNamespaces = mdefNamespaces;
           }
   
  +        public String getCatalogFile()
  +        {
  +            return catalogFile;
  +        }
  +
  +        public void setCatalogFile(String catalogPropFile)
  +        {
  +            this.catalogFile = catalogPropFile;
  +        }
  +
       }
   
       private static SchemaTypeSystem loadTypeSystem(
  @@ -622,7 +641,7 @@
           File[] wsdlFiles, File[] configFiles, ResourceLoader cpResourceLoader,
           boolean download, boolean noUpa, boolean noPvr, boolean noAnn,
           Set mdefNamespaces, File baseDir, Map sourcesToCopyMap,
  -        Collection outerErrorListener)
  +        Collection outerErrorListener, File schemasDir, EntityResolver entResolver)
       {
           XmlErrorWatcher errorListener = new XmlErrorWatcher(outerErrorListener);
   
  @@ -645,6 +664,7 @@
                       XmlOptions options = new XmlOptions();
                       options.setLoadLineNumbers();
                       options.setLoadMessageDigest();
  +                    options.setEntityResolver(entResolver);
   
                       XmlObject schemadoc = loader.parse(xsdFiles[i], null, options);
                       if (!(schemadoc instanceof SchemaDocument))
  @@ -682,7 +702,7 @@
                       options.setLoadSubstituteNamespaces(Collections.singletonMap(
                               "http://schemas.xmlsoap.org/wsdl/", "http://www.apache.org/internal/xmlbeans/wsdlsubst"
                       ));
  -
  +                    options.setEntityResolver(entResolver);
   
                       XmlObject wsdldoc = loader.parse(wsdlFiles[i], null, options);
   
  @@ -732,6 +752,7 @@
                   {
                       XmlOptions options = new XmlOptions();
                       options.put( XmlOptions.LOAD_LINE_NUMBERS );
  +                    options.setEntityResolver(entResolver);
   
                       XmlObject configdoc = loader.parse(configFiles[i], null, options);
                       if (!(configdoc instanceof ConfigDocument))
  @@ -773,6 +794,7 @@
           if (mdefNamespaces != null)
               opts.setCompileMdefNamespaces(mdefNamespaces);
           opts.setCompileNoValidation(); // already validated here
  +        opts.setEntityResolver(entResolver);
   
           // now pass it to the main compile function
           SchemaTypeSystemCompiler.Parameters params = new SchemaTypeSystemCompiler.Parameters();
  @@ -785,6 +807,7 @@
           params.setJavaize(true);
           params.setBaseURI(baseURI);
           params.setSourcesToCopyMap(sourcesToCopyMap);
  +        params.setSchemasDir(schemasDir);
           return SchemaTypeSystemCompiler.compile(params);
       }
   
  @@ -818,6 +841,8 @@
           boolean jaxb = params.getJaxb();
           Set mdefNamespaces = params.getMdefNamespaces();
   
  +        EntityResolver cmdLineEntRes = ResolverUtil.resolverForCatalog(params.getCatalogFile());
  +
           if (srcDir == null || classesDir == null)
               throw new IllegalArgumentException("src and class gen directories may not be null.");
   
  @@ -836,9 +861,13 @@
   
           boolean result = true;
   
  +        File schemasDir = IOUtil.createDir(classesDir, "schema/src");
  +
           // build the in-memory type system
           XmlErrorWatcher errorListener = new XmlErrorWatcher(outerErrorListener);
  -        SchemaTypeSystem system = loadTypeSystem(name, xsdFiles, wsdlFiles, configFiles, cpResourceLoader, download, noUpa, noPvr, noAnn, mdefNamespaces, baseDir, sourcesToCopyMap, errorListener);
  +        SchemaTypeSystem system = loadTypeSystem(name, xsdFiles, wsdlFiles, configFiles, cpResourceLoader,
  +            download, noUpa, noPvr, noAnn, mdefNamespaces, baseDir, sourcesToCopyMap, errorListener,
  +            schemasDir, cmdLineEntRes);
           if (errorListener.hasError())
               result = false;
           long finish = System.currentTimeMillis();
  @@ -852,7 +881,9 @@
   
               // generate source and .xsb
               List sourcefiles = new ArrayList();
  -            result &= SchemaCodeGenerator.compileTypeSystem(system, srcDir, javaFiles, sourcesToCopyMap, classpath, classesDir, outputJar, nojavac, jaxb, errorListener, repackage, verbose, sourcefiles);
  +            result &= SchemaCodeGenerator.compileTypeSystem(system, srcDir, javaFiles, sourcesToCopyMap,
  +                classpath, classesDir, outputJar, nojavac, jaxb, errorListener, repackage, verbose,
  +                sourcefiles, schemasDir);
               result &= !errorListener.hasError();
   
               if (result)
  
  
  
  1.2       +62 -43    xml-xmlbeans/v2/src/xmlcomp/org/apache/xmlbeans/impl/tool/XMLBean.java
  
  Index: XMLBean.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlcomp/org/apache/xmlbeans/impl/tool/XMLBean.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XMLBean.java	26 Sep 2003 21:23:33 -0000	1.1
  +++ XMLBean.java	16 Dec 2003 22:00:50 -0000	1.2
  @@ -2,7 +2,7 @@
   * The Apache Software License, Version 1.1
   *
   *
  -* Copyright (c) 2003 The Apache Software Foundation.  All rights 
  +* Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
  @@ -10,7 +10,7 @@
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
  -*    notice, this list of conditions and the following disclaimer. 
  +*    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
  @@ -18,19 +18,19 @@
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
  -*    if any, must include the following acknowledgment:  
  +*    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 
  +* 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 
  +*    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 
  +* 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
  @@ -49,7 +49,7 @@
   *
   * 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) 2000-2003 BEA Systems 
  +* originally based on software copyright (c) 2000-2003 BEA Systems
   * Inc., <http://www.bea.com/>. For more information on the Apache Software
   * Foundation, please see <http://www.apache.org/>.
   */
  @@ -73,15 +73,16 @@
   import java.net.URI;
   
   import org.apache.xmlbeans.XmlError;
  +import org.apache.xmlbeans.impl.common.IOUtil;
   
   /**
    * Modeled after Ant's javac and zip tasks.
    *
    * Schema files to process, or directories of schema files, are set with the 'schema'
    * attribute, and can be filtered with 'includes' and 'excludes'.
  - * Alternatively, one or more nested &lt;fileset&gt; elements can specify the 
  + * Alternatively, one or more nested &lt;fileset&gt; elements can specify the
    * files and directories to be used to generate this XMLBean.
  - * The include set can also define .java files that should be built as well.  
  + * The include set can also define .java files that should be built as well.
    * See the FileSet documentation at http://jakarta.apache.org/ant/manual/index.html
    * for instructions on FileSets if you are unfamiliar with their usage.
    */
  @@ -89,14 +90,14 @@
   public class XMLBean extends MatchingTask
   {
       private ArrayList   schemas = new ArrayList();
  -    
  +
       private Path        classpath;
  -    
  +
       private File        destfile,
                           schema,
                           srcgendir,
                           classgendir;
  -    
  +
       private boolean     quiet,
                           verbose,
                           debug,
  @@ -107,14 +108,15 @@
                           fork = true,
                           includeAntRuntime = true,
                           includeJavaRuntime = false;
  -    
  +
       private String      typesystemname,
                           forkedExecutable,
                           compiler,
                           debugLevel,
                           memoryInitialSize,
  -                        memoryMaximumSize;
  -    
  +                        memoryMaximumSize,
  +                        catalog;
  +
       private List        extensions = new ArrayList();
   
       private HashMap     _extRouter = new HashMap(5);
  @@ -142,7 +144,7 @@
                   return;
               }
           }
  -        
  +
           _extRouter.put(XSD, new HashSet());
           _extRouter.put(WSDL, new HashSet());
           _extRouter.put(JAVA, new HashSet());
  @@ -164,10 +166,10 @@
                   processPaths(new String[] { schema.getName() }, theBasedir);
               }
           }
  -        
  +
           if (fileset.getDir(project) != null)
               schemas.add(fileset);
  -        
  +
           Iterator si = schemas.iterator();
           while (si.hasNext())
           {
  @@ -181,7 +183,7 @@
   
           Set xsdList = (Set) _extRouter.get(XSD);
           Set wsdlList = (Set) _extRouter.get(WSDL);
  -        
  +
           if (xsdList.size() + wsdlList.size() == 0)
           {
               log("Could not find any xsd or wsdl files to process.", Project.MSG_WARN);
  @@ -220,26 +222,26 @@
                   tmpdir = SchemaCodeGenerator.createTempDir();
               }
               if (srcgendir == null)
  -                srcgendir = SchemaCodeGenerator.createDir(tmpdir, "src");
  +                srcgendir = IOUtil.createDir(tmpdir, "src");
               if (classgendir == null)
  -                classgendir = SchemaCodeGenerator.createDir(tmpdir, "classes");
  -            
  +                classgendir = IOUtil.createDir(tmpdir, "classes");
  +
               // use the system classpath if user didn't provide any
               if (classpath == null)
               {
                   classpath = new Path(project);
                   classpath.concatSystemClasspath();
               }
  -        
  +
               // prepend the output directory on the classpath
               Path.PathElement pathElement = classpath.createPathElement();
               pathElement.setLocation(classgendir);
  -        
  +
               String[] paths = classpath.list();
               File[] cp = new File[paths.length];
               for (int i = 0; i < paths.length; i++)
                   cp[i] = new File(paths[i]);
  -        
  +
               // generate the source
               SchemaCompiler.Parameters params = new SchemaCompiler.Parameters();
               params.setBaseDir(theBasedir);
  @@ -259,6 +261,7 @@
               params.setDownload(download);
               params.setExtensions(extensions);
               params.setErrorListener(err);
  +            params.setCatalogFile(catalog);
               success = SchemaCompiler.compile(params);
   
               if (success && !srconly) {
  @@ -310,7 +313,7 @@
               //interrupted means cancel
               if (e instanceof InterruptedException)
                   throw new BuildException(e);
  -            
  +
               log("Exception while building schemas: " + e.getMessage(), Project.MSG_ERR);
               StringWriter sw = new StringWriter();
               e.printStackTrace(new PrintWriter(sw));
  @@ -366,7 +369,7 @@
        * supplied by other compiled xml beans JAR files, or if .java files are in the
        * schema fileset.
        * @param classpath Optional.
  -     */ 
  +     */
       public void setClasspath(Path classpath)
       {
           if (this.classpath != null)
  @@ -374,7 +377,7 @@
           else
               this.classpath = classpath;
       }
  -    
  +
       /**
        * Adds a path to the classpath.
        */
  @@ -393,10 +396,10 @@
       {
           if (classpath == null)
               classpath = new Path(project);
  -        
  +
           classpath.createPath().setRefid(classpathref);
       }
  -    
  +
       public Path getClasspath()
       {
           return classpath;
  @@ -412,7 +415,7 @@
        * will output the results of this task into a jar with the same name.
        * Optional, defaults to "xmltypes.jar".
        * @param destfile Optional.
  -     */ 
  +     */
       public void setDestfile(File destfile)
       {
           this.destfile = destfile;
  @@ -427,7 +430,7 @@
        * Set a location to generate .java files into.  Optional, defaults to
        * a temp dir.
        * @param srcgendir Optional.
  -     */ 
  +     */
       public void setSrcgendir(File srcgendir)
       {
           this.srcgendir = srcgendir;
  @@ -442,7 +445,7 @@
        * Set a location to generate .class files into.  Optional, defaults to
        * a temp dir.
        * @param classgendir Optional.
  -     */ 
  +     */
       public void setClassgendir(File classgendir)
       {
           this.classgendir = classgendir;
  @@ -457,7 +460,7 @@
       {
           this.compiler = compiler;
       }
  -    
  +
       public boolean isDownload()
       {
           return download;
  @@ -494,7 +497,7 @@
       /**
        * Controls the amount of output.  Defaults to true.
        * @param verbose Optional.
  -     */ 
  +     */
       public void setVerbose(boolean verbose)
       {
           this.verbose = verbose;
  @@ -508,7 +511,7 @@
       /**
        * Controls the amount of output.  Defaults to false.
        * @param quiet Optional.
  -     */ 
  +     */
       public void setQuiet(boolean quiet)
       {
           this.quiet = quiet;
  @@ -546,7 +549,7 @@
       /**
        * Generate debugging symbols.
        * @param debug Optional.
  -     */ 
  +     */
       public void setDebug(boolean debug)
       {
           this.debug = debug;
  @@ -584,12 +587,12 @@
        * A value of true means that only source will be generated.  Optional,
        * default is false.
        * @param srconly Optional.
  -     */ 
  +     */
       public void setSrconly(boolean srconly)
       {
           this.srconly = srconly;
       }
  - 
  +
       public String getTypesystemname()
       {
           return typesystemname;
  @@ -606,12 +609,12 @@
       }
   
       /**
  -     * The name of the package that the TypeSystemHolder class should be 
  +     * The name of the package that the TypeSystemHolder class should be
        * generated in. Normally this should be left unspecified.  None of
        * the xml beans are generated in this package.
        * <BR><BR>Use .xsdconfig files to modify xml bean package or class names.
        * @param typesystemname Optional.
  -     */ 
  +     */
       public void setTypesystemname(String typesystemname)
       {
           this.typesystemname = typesystemname;
  @@ -626,7 +629,7 @@
        * Determines whether or not the ant target will continue if the XMLBean
        * creation encounters a build error.  Defaults to true.  Optional.
        * @param failonerror Optional.
  -     */ 
  +     */
       public void setFailonerror(boolean failonerror)
       {
           this.failonerror = failonerror;
  @@ -676,6 +679,22 @@
       public void setMemoryMaximumSize(String memoryMaximumSize)
       {
           this.memoryMaximumSize = memoryMaximumSize;
  +    }
  +
  +    /**
  +     * Gets the XML Catalog file for org.apache.xml.resolver.tools.CatalogResolver. (Note: needs resolver.jar from http://xml.apache.org/commons/components/resolver/index.html)
  +     */
  +    public String getCatalog()
  +    {
  +        return catalog;
  +    }
  +
  +    /**
  +     * Sets the XML Catalog file for org.apache.xml.resolver.tools.CatalogResolver. (Note: needs resolver.jar from http://xml.apache.org/commons/components/resolver/index.html)
  +     */
  +    public void setCatalog(String catalog)
  +    {
  +        this.catalog = catalog;
       }
   
       private static URI uriFromFile(File f)
  
  
  
  1.4       +9 -3      xml-xmlbeans/v2/src/xmlstore/org/apache/xmlbeans/impl/store/Root.java
  
  Index: Root.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/xmlstore/org/apache/xmlbeans/impl/store/Root.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Root.java	7 Oct 2003 04:08:03 -0000	1.3
  +++ Root.java	16 Dec 2003 22:00:50 -0000	1.4
  @@ -61,6 +61,7 @@
   import org.apache.xmlbeans.impl.common.EncodingMap;
   import org.apache.xmlbeans.impl.common.QNameHelper;
   import org.apache.xmlbeans.impl.common.XMLNameHelper;
  +import org.apache.xmlbeans.impl.common.ResolverUtil;
   import org.apache.xmlbeans.impl.store.Splay.Finish;
   import org.apache.xmlbeans.impl.values.NamespaceManager;
   import org.apache.xmlbeans.impl.values.XmlStore;
  @@ -733,12 +734,13 @@
                       xr.setFeature( "http://xml.org/sax/features/namespace-prefixes", true );
                       xr.setFeature( "http://xml.org/sax/features/namespaces", true );
                       xr.setFeature( "http://xml.org/sax/features/validation", false );
  -
  -
                       xr.setProperty( "http://xml.org/sax/properties/lexical-handler", this );
                       xr.setContentHandler( this );
                       xr.setErrorHandler( this );
  -                    xr.setEntityResolver( this );
  +                    EntityResolver entRes = ResolverUtil.getGlobalEntityResolver();
  +                    if (entRes==null)
  +                        entRes = this;
  +                    xr.setEntityResolver( entRes );
                   }
                   catch ( Throwable e )
                   {
  @@ -764,6 +766,10 @@
           public void load ( Root r, InputSource inputSource, XmlOptions options )
               throws IOException, XmlException
           {
  +            EntityResolver er = (options==null ? null : (EntityResolver)options.get(XmlOptions.ENTITY_RESOLVER));
  +            if (er!=null)
  +                _xr.setEntityResolver(er);
  +
               LoadContext context = new LoadContext( r, options );
               
               setContext( context, options );
  
  
  
  1.1                  xml-xmlbeans/v2/test/cases/xmlcatalog/MOVEDincluded.xsd
  
  Index: MOVEDincluded.xsd
  ===================================================================
  <xs:schema
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     elementFormDefault="qualified">
  
    <xs:element name="chain" type="chainlink"/>
  
    <xs:complexType name="chainlink">
      <xs:sequence>
        <xs:element ref="chain"/>
      </xs:sequence>
      <xs:attribute ref="name"/>
    </xs:complexType>
  
    <xs:simpleType name="token">
      <xs:restriction base="xs:token">
        <xs:maxLength value="5"/>
      </xs:restriction>
    </xs:simpleType>
  
    <xs:attribute name="name" type="token"/>
  
  </xs:schema>
  
  
  
  1.1                  xml-xmlbeans/v2/test/cases/xmlcatalog/cat.xml
  
  Index: cat.xml
  ===================================================================
  <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
  
  <system systemId="file:/C:/dev/xml-xmlbeans/v2/test/cases/xmlcatalog/included.xsd"
          uri="file:/C:/dev/xml-xmlbeans/v2/test/cases/xmlcatalog/MOVEDincluded.xsd"/>
  
  </catalog>
  
  
  1.1                  xml-xmlbeans/v2/test/cases/xmlcatalog/includer1.xsd
  
  Index: includer1.xsd
  ===================================================================
  <xs:schema
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns:tns="http://openuri.org/includer1"
     targetNamespace="http://openuri.org/includer1"
     elementFormDefault="qualified">
  
    <xs:include schemaLocation="included.xsd"/>
  
    <xs:element name="onechain">
      <xs:complexType>
        <xs:sequence>
          <xs:element ref="tns:chain"/>
        </xs:sequence>
      </xs:complexType>
    </xs:element>
  
  </xs:schema>
  
  
  
  1.1                  xml-xmlbeans/v2/test/cases/xmlcatalog/includer2.xsd
  
  Index: includer2.xsd
  ===================================================================
  <xs:schema
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     xmlns:tns="http://openuri.org/includer2"
     targetNamespace="http://openuri.org/includer2"
     elementFormDefault="qualified">
  
    <xs:include schemaLocation="included.xsd"/>
  
    <xs:element name="twochains">
      <xs:complexType>
        <xs:sequence>
          <xs:element ref="tns:chain" minOccurs="2" maxOccurs="2"/>
        </xs:sequence>
      </xs:complexType>
    </xs:element>
  
  </xs:schema>
  
  
  
  1.2       +56 -0     xml-xmlbeans/v2/test/src/drt/drtcases/NumeralsTests.java
  
  Index: NumeralsTests.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/drt/drtcases/NumeralsTests.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NumeralsTests.java	2 Dec 2003 22:48:21 -0000	1.1
  +++ NumeralsTests.java	16 Dec 2003 22:00:50 -0000	1.2
  @@ -1,3 +1,59 @@
  +/*
  +* 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) 2000-2003 BEA Systems
  +* Inc., <http://www.bea.com/>. For more information on the Apache Software
  +* Foundation, please see <http://www.apache.org/>.
  +*/
  +
   package drtcases;
   
   import junit.framework.TestCase;
  
  
  
  1.2       +57 -2     xml-xmlbeans/v2/test/src/drt/drtcases/RichParserTests.java
  
  Index: RichParserTests.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/drt/drtcases/RichParserTests.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RichParserTests.java	2 Dec 2003 22:48:21 -0000	1.1
  +++ RichParserTests.java	16 Dec 2003 22:00:50 -0000	1.2
  @@ -1,3 +1,59 @@
  +/*
  +* 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) 2000-2003 BEA Systems
  +* Inc., <http://www.bea.com/>. For more information on the Apache Software
  +* Foundation, please see <http://www.apache.org/>.
  +*/
  +
   package drtcases;
   
   import junit.framework.Assert;
  @@ -17,11 +73,10 @@
   import javax.xml.stream.XMLStreamException;
   import javax.xml.stream.XMLStreamReader;
   import javax.xml.stream.events.XMLEvent;
  +import java.io.File;
   import java.io.FileInputStream;
   import java.io.IOException;
   import java.io.InputStream;
  -import java.io.File;
  -import java.io.FileNotFoundException;
   import java.math.BigDecimal;
   import java.math.BigInteger;
   import java.util.Calendar;
  
  
  

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