You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by le...@apache.org on 2002/06/13 20:16:02 UTC

cvs commit: xml-xerces/java/src/org/w3c/dom DOMImplementationRegistry.java DOMImplementationSource.java

lehors      2002/06/13 11:16:02

  Modified:    java     build.xml
  Added:       java/src/org/w3c/dom DOMImplementationRegistry.java
                        DOMImplementationSource.java
  Log:
  added a bunch of additional targets for DOM Level 3 support
  
  Revision  Changes    Path
  1.83      +75 -26    xml-xerces/java/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/build.xml,v
  retrieving revision 1.82
  retrieving revision 1.83
  diff -u -r1.82 -r1.83
  --- build.xml	12 Jun 2002 00:27:46 -0000	1.82
  +++ build.xml	13 Jun 2002 18:16:01 -0000	1.83
  @@ -166,9 +166,8 @@
                          **/SchemaImporter.java **/RevalidatingDOMParser.java
                          **/DatatypeContentModel.java **/ComplexTypeInfo.java
                          **/DTDImporter.java **/v1/** **/v2/**
  -                       org/apache/xerces/dom/DOMImplementationSourceImpl.java
                          org/apache/xerces/dom3/*.java
  -                       org/apache/xerces/dom3/ls/*">
  +                       org/apache/xerces/dom3/ls">
           </fileset>
       </copy>
       
  @@ -198,7 +197,7 @@
     </target>
   
     <!-- =================================================================== -->
  -  <!-- Creates the omnibus class package                                           -->
  +  <!-- Creates the omnibus class package                                   -->
     <!-- =================================================================== -->
     <target name="deprecatedjar" depends="compile">
       <jar jarfile="${build.dir}/${deprecatedjar.parser}"
  @@ -208,23 +207,37 @@
     </target>
   
     <!-- =================================================================== -->
  -  <!-- Creates the implementation class package                                           -->
  +  <!-- Creates the implementation class package, excluding DOM Level 3     -->
     <!-- =================================================================== -->
     <target name="jar" depends="compile">
       <jar jarfile="${build.dir}/${jar.parser}"
            basedir="${build.dest}"
            compress="true"
  -         includes="org/apache/**, META-INF/**"/>
  +         includes="org/apache/**, META-INF/**
  +                   org/w3c/dom/ls/**
  +                   org/w3c/dom/DOMError.class
  +                   org/w3c/dom/DOMErrorHandler.class
  +                   org/w3c/dom/DOMImplementationSource.class
  +                   org/w3c/dom/DOMImplementationRegistry.class
  +                   org/w3c/dom/DOMLocator.class
  +                   org/w3c/dom/UserDataHandler.class"/>
     </target>
   
     <!-- =================================================================== -->
  -  <!-- Creates the API class package                                           -->
  +  <!-- Creates the API class package, excluding DOM Level 3                -->
     <!-- =================================================================== -->
     <target name="apijar" depends="compile">
       <jar jarfile="${build.dir}/${jar.apis}"
            basedir="${build.dest}"
            compress="true"
  -         includes="org/xml/**, org/w3c/**, javax/**"/>
  +         includes="org/xml/**, org/w3c/**, javax/**"
  +         excludes="org/w3c/dom/ls
  +                   org/w3c/dom/DOMError.class
  +                   org/w3c/dom/DOMErrorHandler.class
  +                   org/w3c/dom/DOMImplementationSource.class
  +                   org/w3c/dom/DOMImplementationRegistry.class
  +                   org/w3c/dom/DOMLocator.class
  +                   org/w3c/dom/UserDataHandler.class" />
     </target>
   
     <!-- =================================================================== -->
  @@ -250,8 +263,7 @@
     <target name="tests" depends="samples">
       <mkdir dir="${build.tests}"/>
       <copy todir="${build.tests}">
  -        <fileset dir="${tests.dir}"
  -           excludes="**/dom/registry" />
  +        <fileset dir="${tests.dir}" />
       </copy>
       <javac srcdir="${build.tests}"
              destdir="${build.dest}"
  @@ -440,7 +452,7 @@
     </target>
   
     <!-- =================================================================== -->
  -  <!-- Prepares the tools distribution                                    -->
  +  <!-- Prepares the tools distribution                                     -->
     <!-- =================================================================== -->
     <target name="pack-tools" depends="init">
       <echo message="Building the tools distribution files (zip,tar)"/>
  @@ -470,7 +482,7 @@
     </target>
   
     <!-- =================================================================== -->
  -  <!-- Prepares common parts of the binary distributions                                    -->
  +  <!-- Prepares common parts of the binary distributions                   -->
     <!-- =================================================================== -->
     <target name="pack-bin-common" depends="javadocs, docs, sampjar">
   
  @@ -544,7 +556,7 @@
     </target>
   
     <!-- =================================================================== -->
  -  <!-- Prepares the deprecated binary distribution                                    -->
  +  <!-- Prepares the deprecated binary distribution                         -->
     <!-- =================================================================== -->
     <target name="deprecated-bin" depends="pack-bin-common, deprecatedjars">
       <copy file="${build.dir}/${deprecatedjar.parser}" tofile="${distbin.dir}/${deprecatedjar.parser}"/>
  @@ -640,25 +652,25 @@
     </target>
   
     <!-- =================================================================== -->
  -  <!-- Builds both deprecated xerces and sample jar files                             -->
  +  <!-- Builds both deprecated xerces and sample jar files                  -->
     <!-- =================================================================== -->
     <target name="deprecatedjars" depends="deprecatedjar, sampjar">
     </target>
   
     <!-- =================================================================== -->
  -  <!-- Builds xercesImpl, xmlParserAPIs and sample jar files                             -->
  +  <!-- Builds xercesImpl, xmlParserAPIs and sample jar files               -->
     <!-- =================================================================== -->
     <target name="jars" depends="jar, sampjar, apijar">
     </target>
   
     <!-- =================================================================== -->
  -  <!-- Builds and packages tools, sources and binary distributions                -->
  +  <!-- Builds and packages tools, sources and binary distributions         -->
     <!-- =================================================================== -->
     <target name="all" depends="pack-bin, deprecated-bin, pack-src, pack-tools">
     </target>
   
     <!-- =================================================================== -->
  -  <!-- Builds and packages tools, sources and binary distributions                -->
  +  <!-- Builds and packages tools, sources and binary distributions         -->
     <!-- =================================================================== -->
     <target name="deprecatedall" depends="pack-src, deprecated-bin, pack-tools">
     </target>
  @@ -684,7 +696,7 @@
     </target>
   
     <!-- =================================================================== -->
  -  <!-- Creates the DTD-only implementation class package                                           -->
  +  <!-- Creates the DTD-only implementation class package                   -->
     <!-- =================================================================== -->
     <target name="dtdjar" depends="dtdcompile">
       <jar jarfile="${build.dir}/${jar.parser}"
  @@ -694,7 +706,7 @@
     </target>
   
     <!-- =================================================================== -->
  -  <!-- Compiles the DTD-only source directory                                       -->
  +  <!-- Compiles the DTD-only source directory                              -->
     <!-- =================================================================== -->
     <target name="dtdcompile" depends="dtdprepare-src">
       <copy todir="${build.dest}">
  @@ -761,13 +773,13 @@
     </target>
   
     <!-- =================================================================== -->
  -  <!-- Builds xercesImpl (DTD-only), xmlParserAPIs and sample jar files                             -->
  +  <!-- Builds xercesImpl (DTD-only), xmlParserAPIs and sample jar files    -->
     <!-- =================================================================== -->
     <target name="dtdjars" depends="dtdjar, sampjar, apijar">
     </target>
   
     <!-- =================================================================== -->
  -  <!-- Creates the tiny implementation class package                                           -->
  +  <!-- Creates the tiny implementation class package                       -->
     <!-- =================================================================== -->
     <target name="tinyjar" depends="tinycompile">
       <jar jarfile="${build.dir}/${jar.parser}"
  @@ -777,7 +789,7 @@
     </target>
   
     <!-- =================================================================== -->
  -  <!-- Compiles the tiny source directory                                       -->
  +  <!-- Compiles the tiny source directory                                  -->
     <!-- =================================================================== -->
     <target name="tinycompile" depends="tinyprepare-src">
       <copy todir="${build.dest}">
  @@ -797,7 +809,7 @@
   
   
     <!-- =================================================================== -->
  -  <!-- Compiles the tiny source code package                                    -->
  +  <!-- Compiles the tiny source code package                               -->
     <!-- =================================================================== -->
     <target name="tinyprepare-src" depends="prepare-common">
       <copy file="${src.dir}/org/apache/xerces/parsers/org.apache.xerces.xni.parser.DTDConfiguration"
  @@ -846,7 +858,7 @@
     </target>
   
     <!-- =================================================================== -->
  -  <!-- Builds xercesImpl (tiny), xmlParserAPIs and sample jar files                             -->
  +  <!-- Builds xercesImpl (tiny), xmlParserAPIs, and sample jars            -->
     <!-- =================================================================== -->
     <target name="tinyjars" depends="tinyjar, sampjar, apijar">
     </target>
  @@ -912,7 +924,7 @@
                          **/DatatypeContentModel.java **/ComplexTypeInfo.java
                          **/DTDImporter.java **/v1/** **/v2/**
                 	       org/apache/xerces/dom3/*.java
  -              	       org/apache/xerces/dom3/ls/*
  +              	       org/apache/xerces/dom3/ls
                          org/w3c/dom/*.java">
           </fileset>
       </copy>
  @@ -984,7 +996,7 @@
     </target>
   
     <!-- =================================================================== -->
  -  <!-- Do a sanity test using samples                                      -->
  +  <!-- Do a sanity test using samples with DOM Level 3                     -->
     <!-- =================================================================== -->
     <target name="test-dom3" depends="tests-dom3">
       <echo message="Performing sanity test for ${parser.Name} ${parser.Version} ..." />
  @@ -1056,6 +1068,43 @@
             classname="dom.DTest"
             failOnError="yes">
       </java>
  +  </target>
  +
  +  <!-- =================================================================== -->
  +  <!-- Creates the implementation class package with DOM Level 3           -->
  +  <!-- =================================================================== -->
  +  <target name="jar-dom3" depends="compile-dom3">
  +    <jar jarfile="${build.dir}/${jar.parser}"
  +         basedir="${build.dest}"
  +         compress="true"
  +         includes="org/apache/**, META-INF/**" />
  +  </target>
  +
  +  <!-- =================================================================== -->
  +  <!-- Creates the API class package with DOM Level 3                      -->
  +  <!-- =================================================================== -->
  +  <target name="apijar-dom3" depends="compile-dom3">
  +    <jar jarfile="${build.dir}/${jar.apis}"
  +         basedir="${build.dest}"
  +         compress="true"
  +         includes="org/xml/**, org/w3c/**, javax/**" />
  +  </target>
  +
  +
  +  <!-- =================================================================== -->
  +  <!-- Creates the samples package with DOM Level 3                        -->
  +  <!-- =================================================================== -->
  +  <target name="sampjar-dom3" depends="samples-dom3">
  +    <jar jarfile="${build.dir}/${jar.samples}"
  +         basedir="${build.dest}"
  +         compress="true"
  +         includes="dom/**,sax/**,socket/**,ui/**,xni/**"/>
  +  </target>
  +
  +  <!-- =================================================================== -->
  +  <!-- Builds xercesImpl, xmlParserAPIs, and sample jars with DOM Level 3  -->
  +  <!-- =================================================================== -->
  +  <target name="jars-dom3" depends="jar-dom3, sampjar-dom3, apijar-dom3">
     </target>
   
   </project>
  
  
  
  1.1                  xml-xerces/java/src/org/w3c/dom/DOMImplementationRegistry.java
  
  Index: DOMImplementationRegistry.java
  ===================================================================
  /*
   * Copyright (c) 2002 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE.
   * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
   */
  
  
  package org.w3c.dom; 
  
  import java.util.StringTokenizer;
  import java.util.Vector;
  
  /**
   * This class holds the list of registered DOMImplementations. It is first
   * initialized based on the content of the space separated list of classnames
   * contained in the System Property "org.w3c.dom.DOMImplementationSourceList".
   *
   * <p>Subsequently, additional sources can be registered and implementations
   * can be queried based on a list of requested features.
   *
   * <p>This provides an application with an implementation independent starting
   * point.
   *
   * @see DOMImplementation
   * @see DOMImplementationSource
   */
  public class DOMImplementationRegistry 
  { 
  
      // The system property to specify the DOMImplementationSource class names. 
      public static String PROPERTY = "org.w3c.dom.DOMImplementationSourceList";
  
      private static Vector sources = new Vector();
      private static boolean initialized = false;
  
      private static void initialize() throws ClassNotFoundException,
          InstantiationException, IllegalAccessException
      {
          initialized = true;
          String p = System.getProperty(PROPERTY);
          if (p == null) {
              return;
          }
          StringTokenizer st = new StringTokenizer(p);
          while (st.hasMoreTokens()) {
              Object source = Class.forName(st.nextToken()).newInstance();
              sources.addElement(source);
          }
      }
  
      /**
       * Return the first registered implementation that has the desired features,
       * or null if none is found.
       *
       * @param features A string that specifies which features are required.
       *                 This is a space separated list in which each feature is
       *                 specified by its name optionally followed by a space
       *                 and a version number.
       *                 This is something like: "XML 1.0 Traversal Events 2.0"
       * @return An implementation that has the desired features, or
       *   <code>null</code> if this source has none.
       */
      public static DOMImplementation getDOMImplementation(String features)
          throws ClassNotFoundException,
          InstantiationException, IllegalAccessException
      {
          if (!initialized) {
              initialize();
          }
          int len = sources.size(); 
          for (int i = 0; i < len; i++) {
              DOMImplementationSource source =
                  (DOMImplementationSource) sources.elementAt(i);
  
              DOMImplementation impl = source.getDOMImplementation(features);
              if (impl != null) {
                  return impl;
              }
          }
          return null;
      }
  
      /**
       * Register an implementation.
       */
      public static void addSource(DOMImplementationSource s)
          throws ClassNotFoundException,
          InstantiationException, IllegalAccessException
      {
          if (!initialized) {
              initialize();
          }
          sources.addElement(s);
          // update system property accordingly
          StringBuffer b = new StringBuffer(System.getProperty(PROPERTY));
          b.append(" " + s.getClass().getName());
          System.setProperty(PROPERTY, b.toString());
      }
  }
    
  
  
  1.1                  xml-xerces/java/src/org/w3c/dom/DOMImplementationSource.java
  
  Index: DOMImplementationSource.java
  ===================================================================
  /*
   * Copyright (c) 2002 World Wide Web Consortium,
   * (Massachusetts Institute of Technology, Institut National de
   * Recherche en Informatique et en Automatique, Keio University). All
   * Rights Reserved. This program is distributed under the W3C's Software
   * Intellectual Property License. This program is distributed in the
   * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
   * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
   * PURPOSE.
   * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
   */
  
  package org.w3c.dom;
  
  /**
   * This interface permits a DOM implementer to supply one or more 
   * implementations, based upon requested features. Each implemented 
   * <code>DOMImplementationSource</code> object is listed in the 
   * binding-specific list of available sources so that its 
   * <code>DOMImplementation</code> objects are made available.
   * <p>See also the <a href='http://www.w3.org/TR/2002/WD-DOM-Level-3-Core-20020409'>Document Object Model (DOM) Level 3 Core Specification</a>.
   */
  public interface DOMImplementationSource {
      /**
       * A method to request a DOM implementation.
       * @param features A string that specifies which features are required. 
       *   This is a space separated list in which each feature is specified 
       *   by its name optionally followed by a space and a version number. 
       *   This is something like: "XML 1.0 Traversal Events 2.0"
       * @return An implementation that has the desired features, or 
       *   <code>null</code> if this source has none.
       */
      public DOMImplementation getDOMImplementation(String features);
  
  }
  
  
  

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