src/java.xml/share/classes/com/sun/org/apache/xml/internal/resolver/readers/OASISXMLCatalogReader.java
Print this page
@@ -1,19 +1,13 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
- */
-// OASISXMLCatalogReader.java - Read XML Catalog files
-
-/*
- * Copyright 2001-2004 The Apache Software Foundation or its licensors,
- * as applicable.
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
@@ -21,20 +15,20 @@
* limitations under the License.
*/
package com.sun.org.apache.xml.internal.resolver.readers;
-import java.util.Stack;
-import java.util.Vector;
-import java.util.Enumeration;
import com.sun.org.apache.xml.internal.resolver.Catalog;
import com.sun.org.apache.xml.internal.resolver.CatalogEntry;
import com.sun.org.apache.xml.internal.resolver.CatalogException;
import com.sun.org.apache.xml.internal.resolver.helpers.PublicId;
-
-import org.xml.sax.*;
+import java.util.Enumeration;
+import java.util.Stack;
+import java.util.Vector;
+import javax.xml.parsers.SAXParserFactory;
import org.w3c.dom.*;
+import org.xml.sax.*;
/**
* Parse OASIS Entity Resolution Technical Committee
* XML Catalog files.
*
@@ -69,10 +63,21 @@
/** Get the current catalog. */
public Catalog getCatalog () {
return catalog;
}
+ /** Default constructor */
+ public OASISXMLCatalogReader() {
+ super();
+ }
+
+ /** Constructor allowing for providing custom SAX parser factory */
+ public OASISXMLCatalogReader(SAXParserFactory parserFactory, Catalog catalog) {
+ super(parserFactory);
+ setCatalog(catalog);
+ }
+
/**
* Are we in an extension namespace?
*
* @return true if the current stack of open namespaces includes
* an extension namespace.
@@ -100,11 +105,11 @@
/** The SAX <code>setDocumentLocator</code> method does nothing. */
public void setDocumentLocator (Locator locator) {
return;
}
- /** The SAX <code>startDocument</code> method does nothing. */
+ /** The SAX <code>startDocument</code> */
public void startDocument ()
throws SAXException {
baseURIStack.push(catalog.getCurrentBase());
overrideStack.push(catalog.getDefaultOverride());
return;
@@ -369,18 +374,18 @@
} else {
baseURIStack.push(baseURIStack.peek());
}
if (localName.equals("doctype")) {
- entryType = catalog.DOCTYPE;
+ entryType = Catalog.DOCTYPE;
entryArgs.add(atts.getValue("name"));
entryArgs.add(atts.getValue("uri"));
} else if (localName.equals("document")) {
- entryType = catalog.DOCUMENT;
+ entryType = Catalog.DOCUMENT;
entryArgs.add(atts.getValue("uri"));
} else if (localName.equals("dtddecl")) {
- entryType = catalog.DTDDECL;
+ entryType = Catalog.DTDDECL;
entryArgs.add(atts.getValue("publicId"));
entryArgs.add(atts.getValue("uri"));
} else if (localName.equals("entity")) {
entryType = Catalog.ENTITY;
entryArgs.add(atts.getValue("name"));
@@ -430,11 +435,11 @@
String attName2) {
return checkAttributes(atts, attName1)
&& checkAttributes(atts, attName2);
}
- /** The SAX <code>endElement</code> method does nothing. */
+ /** The SAX <code>endElement</code> */
public void endElement (String namespaceURI,
String localName,
String qName)
throws SAXException {
@@ -450,11 +455,11 @@
String popURI = (String) baseURIStack.pop();
String baseURI = (String) baseURIStack.peek();
if (!baseURI.equals(popURI)) {
- entryType = catalog.BASE;
+ entryType = Catalog.BASE;
entryArgs.add(baseURI);
debug.message(4, "(reset) xml:base", baseURI);
try {
@@ -475,11 +480,11 @@
if (localName.equals("catalog") || localName.equals("group")) {
String popOverride = (String) overrideStack.pop();
String override = (String) overrideStack.peek();
if (!override.equals(popOverride)) {
- entryType = catalog.OVERRIDE;
+ entryType = Catalog.OVERRIDE;
entryArgs.add(override);
overrideStack.push(override);
debug.message(4, "(reset) override", override);