/* Woodstox XML processor * * Copyright (c) 2004- Tatu Saloranta, tatu.saloranta@iki.fi * * Licensed under the License specified in the file LICENSE which is * included with the source code. * You may not use this file except in compliance with the License. * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.ctc.wstx.msv; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.TreeSet; import javax.xml.parsers.SAXParserFactory; import javax.xml.stream.XMLStreamException; import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.xml.sax.Locator; import com.ctc.wstx.msv.W3CSchema; import com.sun.msv.grammar.ExpressionPool; import com.sun.msv.grammar.xmlschema.XMLSchemaGrammar; import com.sun.msv.grammar.xmlschema.XMLSchemaSchema; import com.sun.msv.reader.GrammarReaderController; import com.sun.msv.reader.State; import com.sun.msv.reader.xmlschema.EmbeddedSchema; import com.sun.msv.reader.xmlschema.MultiSchemaReader; import com.sun.msv.reader.xmlschema.SchemaState; import com.sun.msv.reader.xmlschema.WSDLGrammarReaderController; import com.sun.msv.reader.xmlschema.XMLSchemaReader; import org.codehaus.stax2.validation.XMLValidationSchema; /** * This is a StAX2 schema factory that can parse and create schema instances * for creating validators that validate documents to check their validity * against specific W3C Schema instances. It requires * Sun Multi-Schema Validator * (http://www.sun.com/software/xml/developers/multischema/) * to work (bundled by Woodstox, no need to add dependency separately, * and acts as a quite thin wrapper layer, similar to * how matching RelaxNG validator works. *
* Note: intentionally does NOT (claim to) implement {@link org.codehaus.stax2.validation.XMLValidationSchemaFactory}
* since interface (that is, {@link W3CMultiSchemaFactory#createSchema(String, Map)})
* is not incompatible with that of other "standard" schema factories; means that
* usage must be explicit, direct and can not be triggered via Stax2 API.
*
* @since 6.2
*
* @author Daniel Kulp
*/
public class W3CMultiSchemaFactory
{
private final SAXParserFactory parserFactory;
public W3CMultiSchemaFactory() {
parserFactory = SAXParserFactory.newInstance();
parserFactory.setNamespaceAware(true);
}
static class RecursiveAllowedXMLSchemaReader extends XMLSchemaReader {
Set