286N/A * reserved comment block 286N/A * DO NOT REMOVE OR ALTER! 286N/A * Copyright 2000-2005 The Apache Software Foundation. 286N/A * Licensed under the Apache License, Version 2.0 (the "License"); 286N/A * you may not use this file except in compliance with the License. 286N/A * You may obtain a copy of the License at 286N/A * Unless required by applicable law or agreed to in writing, software 286N/A * distributed under the License is distributed on an "AS IS" BASIS, 286N/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 286N/A * See the License for the specific language governing permissions and 286N/A * limitations under the License. 286N/A * It also serves as implementation of xs.XSLoader interface and DOMConfiguration interface. 286N/A * This class is designed to interact either with a proxy for a user application 286N/A * which wants to preparse schemas, or with our own Schema validator. 286N/A * It is hoped that none of these "external" classes will therefore need to communicate directly 286N/A * with XSDHandler in future. 286N/A * <p>This class only knows how to make XSDHandler do its thing. 286N/A * The caller must ensure that all its properties (schemaLocation, JAXPSchemaSource 286N/A * etc.) have been properly set. 286N/A * @author Neil Graham, IBM 286N/A // Feature identifiers: 286N/A /** Feature identifier: schema full checking*/ 286N/A /** Feature identifier: continue after fatal error. */ 286N/A /** Feature identifier: allow java encodings to be recognized when parsing schema docs. */ 286N/A /** Feature identifier: standard uri conformant feature. */ 286N/A /** Feature identifier: validate annotations. */ 286N/A /** Feature: disallow doctype*/ 286N/A /** Feature: generate synthetic annotations */ 286N/A /** Feature identifier: honour all schemaLocations */ 286N/A /** Feature identifier: namespace growth */ 286N/A /** Feature identifier: tolerate duplicates */ 286N/A /** Property identifier: Schema DV Factory */ 286N/A // recognized features: 286N/A // property identifiers 286N/A /** Property identifier: symbol table. */ 286N/A /** Property identifier: error reporter. */ 286N/A /** Property identifier: error handler. */ 286N/A /** Property identifier: entity resolver. */ 286N/A /** Property identifier: grammar pool. */ 286N/A /** Property identifier: schema location. */ 286N/A /** Property identifier: no namespace schema location. */ 286N/A /** Property identifier: JAXP schema source. */ 286N/A /** Property identifier: locale. */ 559N/A /** Property identifier: access to external dtd */ 559N/A /** Property identifier: access to external schema */ 286N/A // recognized properties 286N/A // features and properties 286N/A // JAXP property: schema source 286N/A // is Schema Full Checking enabled 286N/A // boolean that tells whether we've tested the JAXP property. 286N/A /** DOM L3 error handler */ 286N/A /** DOM L3 resource resolver */ 286N/A // default constructor. Create objects we absolutely need: 286N/A * This constractor is used by the XMLSchemaValidator. Additional properties, i.e. XMLEntityManager, 286N/A * will be passed during reset(XMLComponentManager). 286N/A // store properties and features in configuration 286N/A // make sure error reporter knows about schemas... 286N/A // entity manager is null if XMLSchemaValidator creates the loader 286N/A // by default augment PSVI (i.e. don't use declaration pool) 286N/A * Returns a list of feature identifiers that are recognized by 286N/A * this XMLGrammarLoader. This method may return null if no features 286N/A }
// getRecognizedFeatures(): String[] 286N/A * Returns the state of a feature. 286N/A * @param featureId The feature identifier. 286N/A * @throws XMLConfigurationException Thrown on configuration error. 286N/A }
// getFeature (String): boolean 286N/A * Sets the state of a feature. 286N/A * @param featureId The feature identifier. 286N/A * @param state The state of the feature. 286N/A * @throws XMLConfigurationException Thrown when a feature is not 286N/A * recognized or cannot be set. 286N/A }
// setFeature(String, boolean) 286N/A * Returns a list of property identifiers that are recognized by 286N/A * this XMLGrammarLoader. This method may return null if no properties 286N/A }
// getRecognizedProperties(): String[] 286N/A * Returns the state of a property. 286N/A * @param propertyId The property identifier. 286N/A * @throws XMLConfigurationException Thrown on configuration error. 286N/A }
// getProperty(String): Object 286N/A * Sets the state of a property. 286N/A * @param propertyId The property identifier. 286N/A * @param state The state of the property. 286N/A * @throws XMLConfigurationException Thrown when a property is not 286N/A * recognized or cannot be set. 286N/A }
// setProperty(String, Object) 286N/A * Set the locale to use for messages. 286N/A * @param locale The locale object to use for localization of messages. 286N/A * @exception XNIException Thrown if the parser does not support the 286N/A /** Return the Locale the XMLGrammarLoader is using. */ 286N/A }
// getLocale(): Locale 286N/A * Sets the error handler. 286N/A * @param errorHandler The error handler. 286N/A }
// setErrorHandler(XMLErrorHandler) 286N/A /** Returns the registered error handler. */ 286N/A }
// getErrorHandler(): XMLErrorHandler 286N/A * Sets the entity resolver. 286N/A * @param entityResolver The new entity resolver. 286N/A }
// setEntityResolver(XMLEntityResolver) 286N/A /** Returns the registered entity resolver. */ 286N/A }
// getEntityResolver(): XMLEntityResolver 286N/A * Returns a Grammar object by parsing the contents of the 286N/A * entities pointed to by sources. 286N/A * @param source[] the locations of the entity which forms 286N/A * the staring point of the grammars to be constructed 286N/A * @throws IOException when a problem is encounted reading the entity 286N/A * @throws XNIException when a condition arises (such as a FatalError) that requires parsing 286N/A * of the entity be terminated 286N/A * Returns a Grammar object by parsing the contents of the 286N/A * entity pointed to by source. 286N/A * @param source the location of the entity which forms 286N/A * the starting point of the grammar to be constructed. 286N/A * @throws IOException When a problem is encountered reading the entity 286N/A * XNIException When a condition arises (such as a FatalError) that requires parsing 286N/A * of the entity be terminated. 286N/A // REVISIT: this method should have a namespace parameter specified by 286N/A // user. In this case we can easily detect if a schema asked to be loaded 286N/A // is already in the local cache. 286N/A // none of the other fields make sense for preparsing 286N/A // Process external schema location properties. 286N/A // We don't call tokenizeSchemaLocationStr here, because we also want 286N/A // to check whether the values are valid URI. 286N/A // NOTE: we only need to verify full checking in case the schema was not provided via JAXP 286N/A // since full checking already verified for all JAXP schemas 286N/A }
// loadGrammar(XMLInputSource): Grammar 286N/A * This method is called either from XMLGrammarLoader.loadGrammar or from XMLSchemaValidator. 286N/A * Note: in either case, the EntityManager (or EntityResolvers) are not going to be invoked 286N/A * to resolve the location of the schema in XSDDescription 286N/A * @return An XML Schema grammar 286N/A // this should only be done once per invocation of this object; 286N/A // unless application alters JAXPSource in the mean time. 559N/A "schema_reference.access",
286N/A }
// loadSchema(XSDDescription, XMLInputSource): SchemaGrammar 286N/A /** This method tries to resolve location of the given schema. 286N/A * namespace of absent namespace). When resolving an entity, loader first tries 286N/A * to find in the hashtable whether there is a value for that namespace, 286N/A * if so, pass that location value to the user-defined entity resolver. 286N/A * @param entityResolver 286N/A // we consider the schema location properties for import 286N/A // use empty string as the key for absent namespace 286N/A // get the location hint for that namespace 286N/A // if it's not import, or if the target namespace is not set 286N/A // in the schema location properties, use location hint 286N/A // add external schema locations to the location pairs 286N/A // get the attribute decl for xsi:schemaLocation 286N/A // because external schema location property has the same syntax 286N/A // as xsi:schemaLocation 286N/A // validation the string value to get the list of URI's 286N/A // report warning (odd number of items) 286N/A // report warning (not list of URI's) 286N/A // similarly for no ns schema location property 286N/A // report warning (not a URI) 286N/A // this method takes a SchemaLocation string. 286N/A // If an error is encountered, false is returned; 286N/A // otherwise, true is returned. In either case, locations 286N/A // is augmented to include as many tokens as possible. 286N/A // @param schemaStr The schemaLocation string to tokenize 286N/A // @param locations HashMap mapping namespaces to LocationArray objects holding lists of locaitons 286N/A // @return true if no problems; false if string could not be tokenized 286N/A return false;
// error! 286N/A }
// tokenizeSchemaLocation(String, HashMap): boolean 286N/A * Translate the various JAXP SchemaSource property types to XNI 286N/A * XMLInputSource. Valid types are: String, org.xml.sax.InputSource, 286N/A * InputStream, File, or Object[] of any of previous types. 286N/A * REVISIT: the JAXP 1.2 spec is less than clear as to whether this property 286N/A * should be available to imported schemas. I have assumed 286N/A * Note: all JAXP schema files will be checked for full-schema validity if the feature was set up 286N/A // it is possible that we won't be able to resolve JAXP schema-source location 286N/A // Not an Object[], String[], File[], InputStream[], InputSource[] 286N/A "}. Possible types of the array supported are Object, String, File, "+
286N/A "InputStream, InputSource.");
286N/A // JAXP spec. allow []s of type String, File, InputStream, 286N/A // InputSource also, apart from [] of type Object. 286N/A //make local vector for storing targetn namespaces of schemasources specified in object arrays. 286N/A //when an array of objects is passed it is illegal to have two schemas that share same namespace. 286N/A " When using array of Objects as the value of SCHEMA_SOURCE property , " +
286N/A "no two Schemas should share the same targetNamespace. " );
286N/A //REVISIT: What should be the acutal behavior if grammar can't be loaded as specified in schema source? 286N/A }
//processJAXPSchemaSource 286N/A // String value is treated as a URI that is passed through the 286N/A // REVISIT: can this happen? 286N/A // Treat value as a URI and pass in as systemId 286N/A "}. Possible types of the value supported are String, File, InputStream, "+
286N/A "InputSource OR an array of these types.");
286N/A //Convert a SAX InputSource to an equivalent XNI XMLInputSource 286N/A // TODO Auto-generated method stub 286N/A // need to reprocess JAXP schema sources 286N/A // reinitialize grammar bucket 286N/A //pass the component manager to the factory.. 286N/A // get registered entity manager to be able to resolve JAXP schema-source property: 286N/A // Note: in case XMLSchemaValidator has created the loader, 286N/A // the entity manager property is null 286N/A // get the error reporter 286N/A // Determine schema dv factory to use 286N/A // get schema location properties 286N/A // get JAXP sources if available 286N/A // clear grammars, and put the one for schema namespace there 286N/A // get continue-after-fatal-error feature 286N/A // set full validation to false 286N/A // get generate-synthetic-annotations feature 286N/A // put this grammar into the bucket, along with grammars 286N/A // imported by it (directly or indirectly) 286N/A // REVISIT: a conflict between new grammar(s) and grammars 286N/A // in the bucket. What to do? A warning? An exception? 286N/A * @see com.sun.org.apache.xerces.internal.xs.XSLoader#getConfig() 286N/A * @see com.sun.org.apache.xerces.internal.xs.XSLoader#load(org.w3c.dom.ls.LSInput) 286N/A * @see com.sun.org.apache.xerces.internal.xs.XSLoader#loadInputList(com.sun.org.apache.xerces.internal.xs.DOMInputList) 286N/A * @see com.sun.org.apache.xerces.internal.xs.XSLoader#loadURI(java.lang.String) 286N/A * @see com.sun.org.apache.xerces.internal.xs.XSLoader#loadURIList(com.sun.org.apache.xerces.internal.xs.StringList) 286N/A * @see DOMConfiguration#canSetParameter(String, Object) 286N/A * @see DOMConfiguration#getParameter(String) 286N/A "FEATURE_NOT_SUPPORTED",
286N/A * @see DOMConfiguration#getParameterNames() 286N/A * @see DOMConfiguration#setParameter(String, Object) 286N/A "FEATURE_NOT_SUPPORTED",
286N/A // REVISIT: type mismatch 286N/A "FEATURE_NOT_SUPPORTED",
286N/A // REVISIT: type mismatch 286N/A "FEATURE_NOT_SUPPORTED",
286N/A "FEATURE_NOT_SUPPORTED",
286N/A // need to wrap the LSInput with an XMLInputSource 286N/A * An LSParser looks at inputs specified in LSInput in 286N/A * the following order: characterStream, byteStream, 286N/A * stringData, systemId, publicId. For consistency 286N/A * have the same behaviour for XSLoader. 286N/A // check whether there is a Reader 286N/A // according to DOM, we need to treat such reader as "UTF-16". 286N/A // check whether there is an InputStream 286N/A // if there is a string data, use a StringReader 286N/A // according to DOM, we need to treat such data as "UTF-16".