Home » xmlbeans-2.5.0-src » org.apache » xmlbeans » [javadoc | source]

    1   /*   Copyright 2004 The Apache Software Foundation
    2    *
    3    *   Licensed under the Apache License, Version 2.0 (the "License");
    4    *   you may not use this file except in compliance with the License.
    5    *   You may obtain a copy of the License at
    6    *
    7    *       http://www.apache.org/licenses/LICENSE-2.0
    8    *
    9    *   Unless required by applicable law or agreed to in writing, software
   10    *   distributed under the License is distributed on an "AS IS" BASIS,
   11    *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   12    *   See the License for the specific language governing permissions and
   13    *  limitations under the License.
   14    */
   15   
   16   package org.apache.xmlbeans;
   17   
   18   import javax.xml.namespace.QName;
   19   import org.apache.xmlbeans.xml.stream.XMLInputStream;
   20   import org.apache.xmlbeans.xml.stream.XMLStreamException;
   21   
   22   import java.io.File;
   23   import java.io.InputStream;
   24   import java.io.IOException;
   25   import java.io.Reader;
   26   import java.net.URL;
   27   
   28   import javax.xml.stream.XMLStreamReader;
   29   
   30   import org.w3c.dom.Node;
   31   import org.w3c.dom.DOMImplementation;
   32   
   33   /**
   34    * Represents a searchable set of XML Schema component definitions.
   35    * <p>
   36    * SchemaTypeLoader is somewhat analogous to {@link java.lang.ClassLoader},
   37    * because it is responsible for finding {@link SchemaComponent} definitions
   38    * by name, yet it is not responsible for being able to enumerate all the
   39    * component definitons available. (If you wish to enumerate component
   40    * definitions, see {@link SchemaTypeSystem}.) There are some ways in which
   41    * SchemaTypeSystems are dissimilar from ClassLoaders, however.
   42    * Since XML Schema has a number of instance-oriented typing mechanisms
   43    * (such as wildcards) that do not exist in Java, a SchemaTypeLoader is
   44    * not associated with a type; instead, a SchemaTypeLoader is associated
   45    * with each XML instance.
   46    * <p>
   47    * Every XML instance is loaded within the context of a SchemaTypeLoader;
   48    * the SchemaTypeLoader for an instance is used to resolve all type definitions
   49    * within the instance and for applying type-sensitive methods such as
   50    * {@link XmlObject#validate}.
   51    * <p>
   52    * Normally the SchemaTypeLoader being used for all instances is the
   53    * context type loader (that is, the SchemaTypeLoader returned from
   54    * {@link XmlBeans#getContextTypeLoader()}).  The context type loader
   55    * consults the thread's context ClassLoader (see {@link Thread#getContextClassLoader()})
   56    * to find schema type defintions that are available on the classpath.
   57    * The net result is that you can use schema types simply by putting
   58    * their compiled schema JARs on your classpath.
   59    * If you wish to load instances using a different SchemaTypeLoader, then you must
   60    * call {@link #parse} methods on the SchemaTypeLoader instance explicitly
   61    * rather than using the normal convenient Factory methods.
   62    * <p>
   63    * A SchemaTypeLoader can be obtained by dynamically loading XSD files
   64    * using {@link XmlBeans#loadXsd}, or by assembling other SchemaTypeLoaders
   65    * or SchemaTypeSystems on a path using {@link XmlBeans#typeLoaderUnion}.
   66    * 
   67    * @see XmlBeans#loadXsd
   68    * @see XmlBeans#getContextTypeLoader
   69    * @see XmlBeans#typeLoaderUnion
   70    * @see SchemaTypeSystem
   71    */ 
   72   public interface SchemaTypeLoader
   73   {
   74       /** Returns the type with the given name, or null if none. */
   75       public SchemaType findType(QName name);
   76   
   77       /** Returns the document type rooted at the given element name, or null if none. */
   78       public SchemaType findDocumentType(QName name);
   79       
   80       /** Returns the attribute type containing the given attribute name, or null if none. */
   81       public SchemaType findAttributeType(QName name);
   82   
   83       /** Returns the global element defintion with the given name, or null if none. */
   84       public SchemaGlobalElement findElement(QName name);
   85   
   86       /** Returns the global attribute defintion with the given name, or null if none. */
   87       public SchemaGlobalAttribute findAttribute(QName name);
   88       
   89       /** Returns the model group defintion with the given name, or null if none. */
   90       public SchemaModelGroup findModelGroup(QName name);
   91       
   92       /** Returns the attribute group defintion with the given name, or null if none. */
   93       public SchemaAttributeGroup findAttributeGroup(QName name);
   94   
   95       /** True if the typeloader contains any definitions in the given namespace. */
   96       public boolean isNamespaceDefined(String namespace);
   97   
   98       /** Used for on-demand loading. */
   99       public SchemaType.Ref findTypeRef(QName name);
  100   
  101       /** Used for on-demand loading. */
  102       public SchemaType.Ref findDocumentTypeRef(QName name);
  103       
  104       /** Used for on-demand loading. */
  105       public SchemaType.Ref findAttributeTypeRef(QName name);
  106   
  107       /** Used for on-demand loading. */
  108       public SchemaGlobalElement.Ref findElementRef(QName name);
  109   
  110       /** Used for on-demand loading. */
  111       public SchemaGlobalAttribute.Ref findAttributeRef(QName name);
  112       
  113       /** Used for on-demand loading. */
  114       public SchemaModelGroup.Ref findModelGroupRef(QName name);
  115       
  116       /** Used for on-demand loading. */
  117       public SchemaAttributeGroup.Ref findAttributeGroupRef(QName name);
  118   
  119       /** Used for on-demand loading. */
  120       public SchemaIdentityConstraint.Ref findIdentityConstraintRef(QName name);
  121   
  122       /** Finds a type for a given signature string */
  123       public SchemaType typeForSignature(String signature);
  124   
  125       /** Finds a type for a given fully-qualified XML Bean classname */
  126       public SchemaType typeForClassname(String classname);
  127   
  128       /** Loads original XSD source as a stream.  See {@link SchemaType#getSourceName}. */
  129       public InputStream getSourceAsStream(String sourceName);
  130       
  131       /** Compiles an XPath */
  132       public String compilePath(String pathExpr, XmlOptions options) throws XmlException;
  133   
  134       /** Compiles an XQuery */
  135       public String compileQuery(String queryExpr, XmlOptions options) throws XmlException;
  136   
  137       /** Creates an instance of the given type. */
  138       public XmlObject newInstance ( SchemaType type, XmlOptions options );
  139       /** Parses an instance of the given type. */
  140       public XmlObject parse ( String xmlText, SchemaType type, XmlOptions options ) throws XmlException;
  141       /** Parses an instance of the given type. */
  142       public XmlObject parse ( File file, SchemaType type, XmlOptions options ) throws XmlException, IOException;
  143       /** Parses an instance of the given type. */
  144       public XmlObject parse ( URL file, SchemaType type, XmlOptions options ) throws XmlException, IOException;
  145       /** Parses an instance of the given type. */
  146       public XmlObject parse ( InputStream jiois, SchemaType type, XmlOptions options ) throws XmlException, IOException;
  147       /** Parses an instance of the given type. */
  148       public XmlObject parse ( XMLStreamReader xsr, SchemaType type, XmlOptions options ) throws XmlException;
  149       /** Parses an instance of the given type. */
  150       public XmlObject parse ( Reader jior, SchemaType type, XmlOptions options ) throws XmlException, IOException;
  151       /** Parses an instance of the given type. */
  152       public XmlObject parse ( Node node, SchemaType type, XmlOptions options ) throws XmlException;
  153       /** Parses an instance of the given type.
  154        * @deprecated Deprecated by XMLStreamReader from STaX - jsr173 API.
  155        */
  156       public XmlObject parse ( XMLInputStream xis, SchemaType type, XmlOptions options ) throws XmlException, XMLStreamException;
  157       /** Returns an XmlSaxHandler that can parse an instance of the given type. */
  158       public XmlSaxHandler newXmlSaxHandler ( SchemaType type, XmlOptions options );
  159       /** Returns a DOMImplementation. */
  160       public DOMImplementation newDomImplementation ( XmlOptions options );
  161       /** Returns a validating XMLInputStream that will throw an exception if the XML is not valid
  162        * @deprecated Deprecated by XMLStreamReader from STaX - jsr173 API.
  163        */
  164       public XMLInputStream newValidatingXMLInputStream ( XMLInputStream xis, SchemaType type, XmlOptions options ) throws XmlException, XMLStreamException;
  165   }

Home » xmlbeans-2.5.0-src » org.apache » xmlbeans » [javadoc | source]