1 /* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5 // ResolvingXMLReader.java - An XMLReader that performs catalog resolution 6 7 /* 8 * Copyright 2001-2004 The Apache Software Foundation or its licensors, 9 * as applicable. 10 * 11 * Licensed under the Apache License, Version 2.0 (the "License"); 12 * you may not use this file except in compliance with the License. 13 * You may obtain a copy of the License at 14 * 15 * http://www.apache.org/licenses/LICENSE-2.0 16 * 17 * Unless required by applicable law or agreed to in writing, software 18 * distributed under the License is distributed on an "AS IS" BASIS, 19 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 * See the License for the specific language governing permissions and 21 * limitations under the License. 22 */ 23 24 package com.sun.org.apache.xml.internal.resolver.tools; 25 26 import org.xml.sax.*; 27 28 import javax.xml.parsers.*; 29 30 import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl; 31 import com.sun.org.apache.xml.internal.resolver.*; 32 33 /** 34 * A SAX XMLReader that performs catalog-based entity resolution. 35 * 36 * <p>This class implements a SAX XMLReader that performs entity resolution 37 * using the CatalogResolver. The actual, underlying parser is obtained 38 * from a SAXParserFactory.</p> 39 * </p> 40 * 41 * @see CatalogResolver 42 * @see org.xml.sax.XMLReader 43 * 44 * @author Norman Walsh 45 * <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a> 46 * 47 * @version 1.0 48 */ 49 public class ResolvingXMLReader extends ResolvingXMLFilter { 50 /** Make the parser Namespace aware? */ 51 public static boolean namespaceAware = true; 52 53 /** Make the parser validating? */ 54 public static boolean validating = false; 55 56 /** 57 * Construct a new reader from the JAXP factory. 58 * 59 * <p>In order to do its job, a ResolvingXMLReader must in fact be 60 * a filter. So the only difference between this code and the filter 61 * code is that the constructor builds a new reader.</p> 62 */ 63 public ResolvingXMLReader() { 64 super(); 65 SAXParserFactory spf = catalogManager.useServicesMechanism() ? 66 SAXParserFactory.newInstance() : new SAXParserFactoryImpl(); 67 spf.setNamespaceAware(namespaceAware); 68 spf.setValidating(validating); 69 try { 70 SAXParser parser = spf.newSAXParser(); 71 setParent(parser.getXMLReader()); 72 } catch (Exception ex) { 73 ex.printStackTrace(); 74 } | 1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package com.sun.org.apache.xml.internal.resolver.tools; 19 20 21 import javax.xml.parsers.*; 22 23 import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl; 24 import com.sun.org.apache.xml.internal.resolver.*; 25 26 /** 27 * A SAX XMLReader that performs catalog-based entity resolution. 28 * 29 * <p>This class implements a SAX XMLReader that performs entity resolution 30 * using the CatalogResolver. The actual, underlying parser is obtained 31 * from a SAXParserFactory.</p> 32 * </p> 33 * 34 * @see CatalogResolver 35 * @see org.xml.sax.XMLReader 36 * 37 * @author Norman Walsh 38 * <a href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</a> 39 * 40 * @version 1.0 41 */ 42 public class ResolvingXMLReader extends ResolvingXMLFilter { 43 /** Make the parser Namespace aware? */ 44 private static final boolean namespaceAware = true; 45 46 /** Make the parser validating? */ 47 private static final boolean validating = false; 48 49 /** 50 * Construct a new reader from the JAXP factory. 51 * 52 * <p>In order to do its job, a ResolvingXMLReader must in fact be 53 * a filter. So the only difference between this code and the filter 54 * code is that the constructor builds a new reader.</p> 55 */ 56 public ResolvingXMLReader() { 57 super(); 58 SAXParserFactory spf = catalogManager.useServicesMechanism() ? 59 SAXParserFactory.newInstance() : new SAXParserFactoryImpl(); 60 spf.setNamespaceAware(namespaceAware); 61 spf.setValidating(validating); 62 try { 63 SAXParser parser = spf.newSAXParser(); 64 setParent(parser.getXMLReader()); 65 } catch (Exception ex) { 66 ex.printStackTrace(); 67 } |