1 /* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5 /* 6 * Copyright 2005 The Apache Software Foundation. 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 21 package com.sun.org.apache.xerces.internal.jaxp.validation; 22 23 import com.sun.org.apache.xerces.internal.impl.Constants; 24 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter; 25 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter; 26 import com.sun.org.apache.xerces.internal.parsers.XML11Configuration; 27 import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager; 28 import com.sun.org.apache.xerces.internal.xni.XNIException; 29 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; 30 import com.sun.org.apache.xerces.internal.xni.parser.XMLParseException; 31 import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration; 32 import java.io.IOException; 33 import java.lang.ref.SoftReference; 34 import javax.xml.XMLConstants; 35 import javax.xml.transform.Result; 36 import javax.xml.transform.Source; 37 import javax.xml.transform.TransformerConfigurationException; 38 import javax.xml.transform.TransformerFactory; 39 import javax.xml.transform.TransformerFactoryConfigurationError; 40 import javax.xml.transform.sax.SAXTransformerFactory; 41 import javax.xml.transform.sax.TransformerHandler; 42 import javax.xml.transform.stream.StreamResult; 43 import javax.xml.transform.stream.StreamSource; 44 import org.xml.sax.SAXException; 45 46 /** 47 * <p>A validator helper for <code>StreamSource</code>s.</p> 48 * 49 * @author Michael Glavassevich, IBM 50 * @author <a href="mailto:Sunitha.Reddy@Sun.com">Sunitha Reddy</a> 51 */ 52 final class StreamValidatorHelper implements ValidatorHelper { 53 54 // feature identifiers 55 56 /** Feature identifier: parser settings. */ 57 private static final String PARSER_SETTINGS = 58 Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS; 59 60 // property identifiers 61 62 /** Property identifier: entity resolver. */ 63 private static final String ENTITY_RESOLVER = 173 } 174 config.setProperty(ENTITY_RESOLVER, fComponentManager.getProperty(ENTITY_RESOLVER)); 175 config.setProperty(ERROR_HANDLER, fComponentManager.getProperty(ERROR_HANDLER)); 176 XMLErrorReporter errorReporter = (XMLErrorReporter) fComponentManager.getProperty(ERROR_REPORTER); 177 config.setProperty(ERROR_REPORTER, errorReporter); 178 // add message formatters 179 if (errorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) { 180 XMLMessageFormatter xmft = new XMLMessageFormatter(); 181 errorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft); 182 errorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft); 183 } 184 config.setProperty(SYMBOL_TABLE, fComponentManager.getProperty(SYMBOL_TABLE)); 185 config.setProperty(VALIDATION_MANAGER, fComponentManager.getProperty(VALIDATION_MANAGER)); 186 config.setDocumentHandler(fSchemaValidator); 187 config.setDTDHandler(null); 188 config.setDTDContentModelHandler(null); 189 config.setProperty(Constants.XML_SECURITY_PROPERTY_MANAGER, 190 fComponentManager.getProperty(Constants.XML_SECURITY_PROPERTY_MANAGER)); 191 config.setProperty(Constants.SECURITY_MANAGER, 192 fComponentManager.getProperty(Constants.SECURITY_MANAGER)); 193 fConfiguration = new SoftReference(config); 194 return config; 195 } 196 197 } // StreamValidatorHelper | 1 /* 2 * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. 3 */ 4 /* 5 * Licensed to the Apache Software Foundation (ASF) under one or more 6 * contributor license agreements. See the NOTICE file distributed with 7 * this work for additional information regarding copyright ownership. 8 * The ASF licenses this file to You under the Apache License, Version 2.0 9 * (the "License"); you may not use this file except in compliance with 10 * the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 21 package com.sun.org.apache.xerces.internal.jaxp.validation; 22 23 import com.sun.org.apache.xerces.internal.impl.Constants; 24 import com.sun.org.apache.xerces.internal.impl.XMLErrorReporter; 25 import com.sun.org.apache.xerces.internal.impl.msg.XMLMessageFormatter; 26 import com.sun.org.apache.xerces.internal.parsers.XML11Configuration; 27 import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager; 28 import com.sun.org.apache.xerces.internal.xni.XNIException; 29 import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; 30 import com.sun.org.apache.xerces.internal.xni.parser.XMLParseException; 31 import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration; 32 import java.io.IOException; 33 import java.lang.ref.SoftReference; 34 import javax.xml.XMLConstants; 35 import javax.xml.catalog.CatalogFeatures; 36 import javax.xml.transform.Result; 37 import javax.xml.transform.Source; 38 import javax.xml.transform.TransformerConfigurationException; 39 import javax.xml.transform.TransformerFactory; 40 import javax.xml.transform.TransformerFactoryConfigurationError; 41 import javax.xml.transform.sax.SAXTransformerFactory; 42 import javax.xml.transform.sax.TransformerHandler; 43 import javax.xml.transform.stream.StreamResult; 44 import javax.xml.transform.stream.StreamSource; 45 import jdk.xml.internal.JdkXmlFeatures; 46 import jdk.xml.internal.JdkXmlUtils; 47 import org.xml.sax.SAXException; 48 49 /** 50 * <p>A validator helper for <code>StreamSource</code>s.</p> 51 * 52 * @author Michael Glavassevich, IBM 53 * @author <a href="mailto:Sunitha.Reddy@Sun.com">Sunitha Reddy</a> 54 */ 55 final class StreamValidatorHelper implements ValidatorHelper { 56 57 // feature identifiers 58 59 /** Feature identifier: parser settings. */ 60 private static final String PARSER_SETTINGS = 61 Constants.XERCES_FEATURE_PREFIX + Constants.PARSER_SETTINGS; 62 63 // property identifiers 64 65 /** Property identifier: entity resolver. */ 66 private static final String ENTITY_RESOLVER = 176 } 177 config.setProperty(ENTITY_RESOLVER, fComponentManager.getProperty(ENTITY_RESOLVER)); 178 config.setProperty(ERROR_HANDLER, fComponentManager.getProperty(ERROR_HANDLER)); 179 XMLErrorReporter errorReporter = (XMLErrorReporter) fComponentManager.getProperty(ERROR_REPORTER); 180 config.setProperty(ERROR_REPORTER, errorReporter); 181 // add message formatters 182 if (errorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) { 183 XMLMessageFormatter xmft = new XMLMessageFormatter(); 184 errorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft); 185 errorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft); 186 } 187 config.setProperty(SYMBOL_TABLE, fComponentManager.getProperty(SYMBOL_TABLE)); 188 config.setProperty(VALIDATION_MANAGER, fComponentManager.getProperty(VALIDATION_MANAGER)); 189 config.setDocumentHandler(fSchemaValidator); 190 config.setDTDHandler(null); 191 config.setDTDContentModelHandler(null); 192 config.setProperty(Constants.XML_SECURITY_PROPERTY_MANAGER, 193 fComponentManager.getProperty(Constants.XML_SECURITY_PROPERTY_MANAGER)); 194 config.setProperty(Constants.SECURITY_MANAGER, 195 fComponentManager.getProperty(Constants.SECURITY_MANAGER)); 196 197 // Passing on the CatalogFeatures settings 198 JdkXmlUtils.catalogFeaturesConfig2Config(fComponentManager, config); 199 200 fConfiguration = new SoftReference(config); 201 return config; 202 } 203 204 } // StreamValidatorHelper |