You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by le...@apache.org on 2001/03/24 03:45:10 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/xni/parser XMLComponent.java XMLParserConfiguration.java
lehors 01/03/23 18:45:10
Modified: java/src/org/apache/xerces/impl Tag: xerces_j_2
Constants.java XMLDTDScanner.java
XMLDocumentScanner.java XMLEntityManager.java
XMLErrorReporter.java XMLNamespaceBinder.java
XMLScanner.java XMLValidator.java
java/src/org/apache/xerces/impl/validation/validators Tag:
xerces_j_2 XMLDTDValidator.java
XMLSchemaValidator.java
java/src/org/apache/xerces/impl/xpath Tag: xerces_j_2
XPathMatcher.java
java/src/org/apache/xerces/parsers Tag: xerces_j_2
AbstractDOMParser.java AbstractSAXParser.java
AbstractXMLDocumentParser.java
BasicParserConfiguration.java DOMParser.java
SAXParser.java StandardParserConfiguration.java
XMLDocumentParser.java XMLGrammarParser.java
XMLParser.java
java/src/org/apache/xerces/xni/parser Tag: xerces_j_2
XMLComponent.java XMLParserConfiguration.java
Removed: java/src/org/apache/xerces/parsers Tag: xerces_j_2
ParserConfiguration.java
java/src/org/apache/xerces/xni Tag: xerces_j_2
XMLComponent.java XMLComponentManager.java
Log:
Implemented the new xni.parser API.
More work is needed though:
XMLComponent.getRecognizedFeatures/Properties() is commented out for now.
Extended the XMLParserConfiguration interface to implement
set/getFeature and set/getProperty and setLocale.
More thinking is needed here...
Revision Changes Path
No revision
No revision
1.1.2.5 +4 -1 xml-xerces/java/src/org/apache/xerces/impl/Attic/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/Constants.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- Constants.java 2001/03/13 21:19:33 1.1.2.4
+++ Constants.java 2001/03/24 02:45:06 1.1.2.5
@@ -65,7 +65,7 @@
*
* @author Andy Clark, IBM
*
- * @version $Id: Constants.java,v 1.1.2.4 2001/03/13 21:19:33 lehors Exp $
+ * @version $Id: Constants.java,v 1.1.2.5 2001/03/24 02:45:06 lehors Exp $
*/
public final class Constants {
@@ -182,6 +182,9 @@
/** Error handler property ("internal/error-handler"). */
public static final String ERROR_HANDLER_PROPERTY = "internal/error-handler";
+
+ /** Locator property ("internal/locator"). */
+ public static final String LOCATOR_PROPERTY = "internal/locator";
/** Entity manager property ("internal/entity-manager"). */
public static final String ENTITY_MANAGER_PROPERTY = "internal/entity-manager";
1.1.2.81 +3 -3 xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLDTDScanner.java
Index: XMLDTDScanner.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLDTDScanner.java,v
retrieving revision 1.1.2.80
retrieving revision 1.1.2.81
diff -u -r1.1.2.80 -r1.1.2.81
--- XMLDTDScanner.java 2001/03/16 02:26:52 1.1.2.80
+++ XMLDTDScanner.java 2001/03/24 02:45:06 1.1.2.81
@@ -70,13 +70,13 @@
import org.apache.xerces.util.XMLStringBuffer;
import org.apache.xerces.util.SymbolTable;
-import org.apache.xerces.xni.XMLComponent;
-import org.apache.xerces.xni.XMLComponentManager;
import org.apache.xerces.xni.XMLDTDContentModelHandler;
import org.apache.xerces.xni.XMLDTDContentModelSource;
import org.apache.xerces.xni.XMLDTDHandler;
import org.apache.xerces.xni.XMLDTDSource;
import org.apache.xerces.xni.XMLString;
+import org.apache.xerces.xni.parser.XMLComponent;
+import org.apache.xerces.xni.parser.XMLComponentManager;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
@@ -89,7 +89,7 @@
* @author Glenn Marcy, IBM
* @author Eric Ye, IBM
*
- * @version $Id: XMLDTDScanner.java,v 1.1.2.80 2001/03/16 02:26:52 lehors Exp $
+ * @version $Id: XMLDTDScanner.java,v 1.1.2.81 2001/03/24 02:45:06 lehors Exp $
*/
public class XMLDTDScanner
extends XMLScanner
1.1.2.82 +3 -3 xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLDocumentScanner.java
Index: XMLDocumentScanner.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLDocumentScanner.java,v
retrieving revision 1.1.2.81
retrieving revision 1.1.2.82
diff -u -r1.1.2.81 -r1.1.2.82
--- XMLDocumentScanner.java 2001/03/16 02:26:53 1.1.2.81
+++ XMLDocumentScanner.java 2001/03/24 02:45:06 1.1.2.82
@@ -73,11 +73,11 @@
import org.apache.xerces.xni.QName;
import org.apache.xerces.xni.XMLAttributes;
-import org.apache.xerces.xni.XMLComponent;
-import org.apache.xerces.xni.XMLComponentManager;
import org.apache.xerces.xni.XMLDocumentHandler;
import org.apache.xerces.xni.XMLDocumentSource;
import org.apache.xerces.xni.XMLString;
+import org.apache.xerces.xni.parser.XMLComponent;
+import org.apache.xerces.xni.parser.XMLComponentManager;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
@@ -103,7 +103,7 @@
* @author Arnaud Le Hors, IBM
* @author Eric Ye, IBM
*
- * @version $Id: XMLDocumentScanner.java,v 1.1.2.81 2001/03/16 02:26:53 lehors Exp $
+ * @version $Id: XMLDocumentScanner.java,v 1.1.2.82 2001/03/24 02:45:06 lehors Exp $
*/
public class XMLDocumentScanner
extends XMLScanner
1.1.2.73 +3 -3 xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLEntityManager.java
Index: XMLEntityManager.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLEntityManager.java,v
retrieving revision 1.1.2.72
retrieving revision 1.1.2.73
diff -u -r1.1.2.72 -r1.1.2.73
--- XMLEntityManager.java 2000/12/22 19:28:15 1.1.2.72
+++ XMLEntityManager.java 2001/03/24 02:45:06 1.1.2.73
@@ -82,9 +82,9 @@
import org.apache.xerces.util.XMLChar;
import org.apache.xerces.xni.QName;
-import org.apache.xerces.xni.XMLComponent;
-import org.apache.xerces.xni.XMLComponentManager;
import org.apache.xerces.xni.XMLString;
+import org.apache.xerces.xni.parser.XMLComponent;
+import org.apache.xerces.xni.parser.XMLComponentManager;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
@@ -116,7 +116,7 @@
* @author Andy Clark, IBM
* @author Arnaud Le Hors, IBM
*
- * @version $Id: XMLEntityManager.java,v 1.1.2.72 2000/12/22 19:28:15 lehors Exp $
+ * @version $Id: XMLEntityManager.java,v 1.1.2.73 2001/03/24 02:45:06 lehors Exp $
*/
public class XMLEntityManager
implements XMLComponent {
1.1.2.8 +3 -3 xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLErrorReporter.java
Index: XMLErrorReporter.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLErrorReporter.java,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -u -r1.1.2.7 -r1.1.2.8
--- XMLErrorReporter.java 2001/01/05 09:33:27 1.1.2.7
+++ XMLErrorReporter.java 2001/03/24 02:45:06 1.1.2.8
@@ -62,8 +62,8 @@
import org.apache.xerces.util.DefaultErrorHandler;
import org.apache.xerces.util.MessageFormatter;
-import org.apache.xerces.xni.XMLComponent;
-import org.apache.xerces.xni.XMLComponentManager;
+import org.apache.xerces.xni.parser.XMLComponent;
+import org.apache.xerces.xni.parser.XMLComponentManager;
import org.xml.sax.ErrorHandler;
import org.xml.sax.Locator;
@@ -107,7 +107,7 @@
* @author Eric Ye, IBM
* @author Andy Clark, IBM
*
- * @version $Id: XMLErrorReporter.java,v 1.1.2.7 2001/01/05 09:33:27 andyc Exp $
+ * @version $Id: XMLErrorReporter.java,v 1.1.2.8 2001/03/24 02:45:06 lehors Exp $
*/
public class XMLErrorReporter
implements XMLComponent {
1.1.2.5 +3 -3 xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLNamespaceBinder.java
Index: XMLNamespaceBinder.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLNamespaceBinder.java,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -u -r1.1.2.4 -r1.1.2.5
--- XMLNamespaceBinder.java 2001/02/16 08:05:45 1.1.2.4
+++ XMLNamespaceBinder.java 2001/03/24 02:45:06 1.1.2.5
@@ -67,11 +67,11 @@
import org.apache.xerces.xni.QName;
import org.apache.xerces.xni.XMLAttributes;
-import org.apache.xerces.xni.XMLComponent;
-import org.apache.xerces.xni.XMLComponentManager;
import org.apache.xerces.xni.XMLDocumentFilter;
import org.apache.xerces.xni.XMLDocumentHandler;
import org.apache.xerces.xni.XMLString;
+import org.apache.xerces.xni.parser.XMLComponent;
+import org.apache.xerces.xni.parser.XMLComponentManager;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
@@ -93,7 +93,7 @@
*
* @author Andy Clark, IBM
*
- * @version $Id: XMLNamespaceBinder.java,v 1.1.2.4 2001/02/16 08:05:45 andyc Exp $
+ * @version $Id: XMLNamespaceBinder.java,v 1.1.2.5 2001/03/24 02:45:06 lehors Exp $
*/
public class XMLNamespaceBinder
implements XMLComponent, XMLDocumentFilter {
1.1.2.43 +3 -3 xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLScanner.java
Index: XMLScanner.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLScanner.java,v
retrieving revision 1.1.2.42
retrieving revision 1.1.2.43
diff -u -r1.1.2.42 -r1.1.2.43
--- XMLScanner.java 2001/03/16 02:26:54 1.1.2.42
+++ XMLScanner.java 2001/03/24 02:45:06 1.1.2.43
@@ -67,9 +67,9 @@
import org.apache.xerces.util.XMLStringBuffer;
import org.apache.xerces.util.XMLChar;
import org.apache.xerces.xni.XMLAttributes;
-import org.apache.xerces.xni.XMLComponent;
-import org.apache.xerces.xni.XMLComponentManager;
import org.apache.xerces.xni.XMLString;
+import org.apache.xerces.xni.parser.XMLComponent;
+import org.apache.xerces.xni.parser.XMLComponentManager;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
@@ -94,7 +94,7 @@
* @author Arnaud Le Hors, IBM
* @author Eric Ye, IBM
*
- * @version $Id: XMLScanner.java,v 1.1.2.42 2001/03/16 02:26:54 lehors Exp $
+ * @version $Id: XMLScanner.java,v 1.1.2.43 2001/03/24 02:45:06 lehors Exp $
*/
public abstract class XMLScanner
implements XMLComponent {
1.1.2.67 +3 -3 xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLValidator.java
Index: XMLValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Attic/XMLValidator.java,v
retrieving revision 1.1.2.66
retrieving revision 1.1.2.67
diff -u -r1.1.2.66 -r1.1.2.67
--- XMLValidator.java 2001/03/19 23:08:18 1.1.2.66
+++ XMLValidator.java 2001/03/24 02:45:07 1.1.2.67
@@ -82,8 +82,6 @@
import org.apache.xerces.util.XMLChar;
import org.apache.xerces.xni.QName;
-import org.apache.xerces.xni.XMLComponent;
-import org.apache.xerces.xni.XMLComponentManager;
import org.apache.xerces.xni.XMLString;
import org.apache.xerces.xni.XMLAttributes;
import org.apache.xerces.xni.XMLDocumentFilter;
@@ -92,6 +90,8 @@
import org.apache.xerces.xni.XMLDTDHandler;
import org.apache.xerces.xni.XMLDTDContentModelFilter;
import org.apache.xerces.xni.XMLDTDContentModelHandler;
+import org.apache.xerces.xni.parser.XMLComponent;
+import org.apache.xerces.xni.parser.XMLComponentManager;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
@@ -126,7 +126,7 @@
* @author Andy Clark, IBM
* @author Jeffrey Rodriguez IBM
*
- * @version $Id: XMLValidator.java,v 1.1.2.66 2001/03/19 23:08:18 lehors Exp $
+ * @version $Id: XMLValidator.java,v 1.1.2.67 2001/03/24 02:45:07 lehors Exp $
*/
public class XMLValidator
implements XMLComponent,
No revision
No revision
1.1.2.7 +3 -3 xml-xerces/java/src/org/apache/xerces/impl/validation/validators/Attic/XMLDTDValidator.java
Index: XMLDTDValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/validation/validators/Attic/XMLDTDValidator.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- XMLDTDValidator.java 2001/03/16 02:22:58 1.1.2.6
+++ XMLDTDValidator.java 2001/03/24 02:45:08 1.1.2.7
@@ -69,8 +69,6 @@
import org.apache.xerces.impl.validation.grammars.DTDGrammar;
import org.apache.xerces.util.SymbolTable;
import org.apache.xerces.xni.QName;
-import org.apache.xerces.xni.XMLComponent;
-import org.apache.xerces.xni.XMLComponentManager;
import org.apache.xerces.xni.XMLString;
import org.apache.xerces.xni.XMLAttributes;
import org.apache.xerces.xni.XMLDocumentFilter;
@@ -79,6 +77,8 @@
import org.apache.xerces.xni.XMLDTDHandler;
import org.apache.xerces.xni.XMLDTDContentModelFilter;
import org.apache.xerces.xni.XMLDTDContentModelHandler;
+import org.apache.xerces.xni.parser.XMLComponent;
+import org.apache.xerces.xni.parser.XMLComponentManager;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
@@ -87,7 +87,7 @@
/**
* @author Eric Ye, IBM
*
- * @version $Id: XMLDTDValidator.java,v 1.1.2.6 2001/03/16 02:22:58 lehors Exp $
+ * @version $Id: XMLDTDValidator.java,v 1.1.2.7 2001/03/24 02:45:08 lehors Exp $
*/
public class XMLDTDValidator
extends XMLValidator {
1.1.2.3 +3 -3 xml-xerces/java/src/org/apache/xerces/impl/validation/validators/Attic/XMLSchemaValidator.java
Index: XMLSchemaValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/validation/validators/Attic/XMLSchemaValidator.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- XMLSchemaValidator.java 2001/03/16 02:22:59 1.1.2.2
+++ XMLSchemaValidator.java 2001/03/24 02:45:08 1.1.2.3
@@ -64,8 +64,6 @@
import org.apache.xerces.impl.validation.grammars.DTDGrammar;
import org.apache.xerces.util.SymbolTable;
import org.apache.xerces.xni.QName;
-import org.apache.xerces.xni.XMLComponent;
-import org.apache.xerces.xni.XMLComponentManager;
import org.apache.xerces.xni.XMLString;
import org.apache.xerces.xni.XMLAttributes;
import org.apache.xerces.xni.XMLDocumentFilter;
@@ -74,6 +72,8 @@
import org.apache.xerces.xni.XMLDTDHandler;
import org.apache.xerces.xni.XMLDTDContentModelFilter;
import org.apache.xerces.xni.XMLDTDContentModelHandler;
+import org.apache.xerces.xni.parser.XMLComponent;
+import org.apache.xerces.xni.parser.XMLComponentManager;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
@@ -82,7 +82,7 @@
/**
* @author Eric Ye, IBM
*
- * @version $Id: XMLSchemaValidator.java,v 1.1.2.2 2001/03/16 02:22:59 lehors Exp $
+ * @version $Id: XMLSchemaValidator.java,v 1.1.2.3 2001/03/24 02:45:08 lehors Exp $
*/
public class XMLSchemaValidator
extends XMLValidator {
No revision
No revision
1.1.2.4 +3 -3 xml-xerces/java/src/org/apache/xerces/impl/xpath/Attic/XPathMatcher.java
Index: XPathMatcher.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xpath/Attic/XPathMatcher.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- XPathMatcher.java 2001/01/23 04:47:54 1.1.2.3
+++ XPathMatcher.java 2001/03/24 02:45:08 1.1.2.4
@@ -64,10 +64,10 @@
import org.apache.xerces.xni.NamespaceContext;
import org.apache.xerces.xni.QName;
import org.apache.xerces.xni.XMLAttributes;
-import org.apache.xerces.xni.XMLComponent;
-import org.apache.xerces.xni.XMLComponentManager;
import org.apache.xerces.xni.XMLDocumentFragmentHandler;
import org.apache.xerces.xni.XMLString;
+import org.apache.xerces.xni.parser.XMLComponent;
+import org.apache.xerces.xni.parser.XMLComponentManager;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
@@ -78,7 +78,7 @@
*
* @author Andy Clark, IBM
*
- * @version $Id: XPathMatcher.java,v 1.1.2.3 2001/01/23 04:47:54 andyc Exp $
+ * @version $Id: XPathMatcher.java,v 1.1.2.4 2001/03/24 02:45:08 lehors Exp $
*/
public class XPathMatcher
implements XMLComponent, XMLDocumentFragmentHandler {
No revision
No revision
1.1.2.6 +4 -3 xml-xerces/java/src/org/apache/xerces/parsers/Attic/AbstractDOMParser.java
Index: AbstractDOMParser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/Attic/AbstractDOMParser.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -r1.1.2.5 -r1.1.2.6
--- AbstractDOMParser.java 2001/02/26 23:32:19 1.1.2.5
+++ AbstractDOMParser.java 2001/03/24 02:45:08 1.1.2.6
@@ -64,6 +64,7 @@
import org.apache.xerces.xni.QName;
import org.apache.xerces.xni.XMLAttributes;
import org.apache.xerces.xni.XMLString;
+import org.apache.xerces.xni.parser.XMLParserConfiguration;
import org.w3c.dom.Attr;
import org.w3c.dom.CDATASection;
@@ -89,7 +90,7 @@
* @author Andy Clark, IBM
*
*
- * @version $Id: AbstractDOMParser.java,v 1.1.2.5 2001/02/26 23:32:19 lehors Exp $ */
+ * @version $Id: AbstractDOMParser.java,v 1.1.2.6 2001/03/24 02:45:08 lehors Exp $ */
public abstract class AbstractDOMParser
extends AbstractXMLDocumentParser {
@@ -126,7 +127,7 @@
//
/** Default constructor. */
- protected AbstractDOMParser(ParserConfiguration config) {
+ protected AbstractDOMParser(XMLParserConfiguration config) {
super(config);
} // <init>(ParserConfiguration)
@@ -148,7 +149,7 @@
*
* @throws SAXException Thrown on initialization error.
*/
- public void reset() throws SAXException {
+ protected void reset() throws SAXException {
super.reset();
// reset dom information
1.1.2.7 +25 -39 xml-xerces/java/src/org/apache/xerces/parsers/Attic/AbstractSAXParser.java
Index: AbstractSAXParser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/Attic/AbstractSAXParser.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -r1.1.2.6 -r1.1.2.7
--- AbstractSAXParser.java 2001/03/19 23:01:55 1.1.2.6
+++ AbstractSAXParser.java 2001/03/24 02:45:08 1.1.2.7
@@ -65,12 +65,14 @@
import org.apache.xerces.xni.QName;
import org.apache.xerces.xni.XMLAttributes;
import org.apache.xerces.xni.XMLString;
+import org.apache.xerces.xni.parser.XMLParserConfiguration;
import org.xml.sax.ContentHandler;
import org.xml.sax.DTDHandler;
import org.xml.sax.DocumentHandler;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
import org.xml.sax.Parser;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
@@ -87,7 +89,7 @@
* @author Stubs generated by DesignDoc on Mon Sep 11 11:10:57 PDT 2000
* @author Andy Clark, IBM
*
- * @version $Id: AbstractSAXParser.java,v 1.1.2.6 2001/03/19 23:01:55 lehors Exp $ */
+ * @version $Id: AbstractSAXParser.java,v 1.1.2.7 2001/03/24 02:45:08 lehors Exp $ */
public abstract class AbstractSAXParser
extends AbstractXMLDocumentParser
implements Parser, XMLReader // SAX1, SAX2
@@ -114,28 +116,21 @@
/** Lexical handler. */
protected LexicalHandler fLexicalHandler;
- // symbols
+ // constants
- /** Symbol: empty string (""). */
- private String fEmptySymbol;
+ static final private String fEmptyString = "";
- // state
+ static final String LOCATOR =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.LOCATOR_PROPERTY;
- /**
- * True if a parse is in progress. This state is needed because
- * some features/properties cannot be set while parsing (e.g.
- * validation and namespaces).
- */
- protected boolean fParseInProgress = false;
-
//
// Constructors
//
/** Default constructor. */
- protected AbstractSAXParser(ParserConfiguration config) {
+ protected AbstractSAXParser(XMLParserConfiguration config) {
super(config);
- } // <init>(ParserConfiguration)
+ } // <init>(XMLParserConfiguration)
//
// XMLDocumentHandler methods
@@ -230,7 +225,7 @@
// SAX2
if (fContentHandler != null) {
- String uri = element.uri != null ? element.uri : fEmptySymbol;
+ String uri = element.uri != null ? element.uri : fEmptyString;
fContentHandler.startElement(uri, element.localpart,
element.rawname, attributes);
}
@@ -305,7 +300,7 @@
// SAX2
if (fContentHandler != null) {
- String uri = element.uri != null ? element.uri : fEmptySymbol;
+ String uri = element.uri != null ? element.uri : fEmptyString;
fContentHandler.endElement(uri, element.localpart,
element.rawname);
}
@@ -697,7 +692,18 @@
*/
public void setDocumentHandler(DocumentHandler documentHandler) {
fDocumentHandler = documentHandler;
- fDocumentHandler.setDocumentLocator(fConfiguration.getLocator());
+ try {
+ Locator locator = (Locator) fConfiguration.getProperty(LOCATOR,
+ false);
+ fDocumentHandler.setDocumentLocator(locator);
+ }
+ catch (SAXNotSupportedException e) {
+ // should not happen
+ }
+ catch (SAXNotRecognizedException e) {
+ // should not happen
+ }
+
} // setDocumentHandler(DocumentHandler)
//
@@ -773,7 +779,6 @@
// SAX2 Features
//
- Hashtable features = fConfiguration.getFeatureTable();
if (featureId.startsWith(Constants.SAX_FEATURE_PREFIX)) {
String feature = featureId.substring(Constants.SAX_FEATURE_PREFIX.length());
@@ -784,7 +789,7 @@
// and xmlns* attributes must not be reported.
//
if (feature.equals(Constants.NAMESPACE_PREFIXES_FEATURE)) {
- features.put(featureId, state ? Boolean.TRUE : Boolean.FALSE);
+ fConfiguration.setFeature(featureId, state, false);
return;
}
// http://xml.org/sax/features/string-interning
@@ -848,7 +853,6 @@
// SAX2 Features
//
- Hashtable features = fConfiguration.getFeatureTable();
if (featureId.startsWith(Constants.SAX_FEATURE_PREFIX)) {
String feature =
featureId.substring(Constants.SAX_FEATURE_PREFIX.length());
@@ -860,8 +864,7 @@
// and xmlns* attributes must not be reported.
//
if (feature.equals(Constants.NAMESPACE_PREFIXES_FEATURE)) {
- Boolean state = (Boolean) features.get(featureId);
- return state.booleanValue();
+ return fConfiguration.getFeature(featureId, false);
}
// http://xml.org/sax/features/string-interning
// controls the use of java.lang.String#intern() for strings
@@ -1167,22 +1170,5 @@
throws SAXNotRecognizedException, SAXNotSupportedException {
return fLexicalHandler;
} // getLexicalHandler():LexicalHandler
-
- //
- // XMLDocumentParser methods
- //
-
- /**
- * Reset all components before parsing.
- *
- * @throws SAXException Thrown if an error occurs during initialization.
- */
- public void reset() throws SAXException {
- super.reset();
-
- // save needed symbols
- fEmptySymbol = fConfiguration.getSymbolTable().addSymbol("");
-
- } // reset()
} // class AbstractSAXParser
1.1.2.4 +52 -7 xml-xerces/java/src/org/apache/xerces/parsers/Attic/AbstractXMLDocumentParser.java
Index: AbstractXMLDocumentParser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/Attic/AbstractXMLDocumentParser.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- AbstractXMLDocumentParser.java 2001/02/26 23:32:19 1.1.2.3
+++ AbstractXMLDocumentParser.java 2001/03/24 02:45:08 1.1.2.4
@@ -58,14 +58,20 @@
package org.apache.xerces.parsers;
+import java.io.IOException;
+
import org.apache.xerces.xni.QName;
import org.apache.xerces.xni.XMLAttributes;
import org.apache.xerces.xni.XMLDocumentHandler;
import org.apache.xerces.xni.XMLDTDHandler;
import org.apache.xerces.xni.XMLDTDContentModelHandler;
import org.apache.xerces.xni.XMLString;
+import org.apache.xerces.xni.parser.XMLParserConfiguration;
+import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+import org.xml.sax.SAXNotSupportedException;
+import org.xml.sax.SAXNotRecognizedException;
/**
* This is the base class for all XML document parsers. XMLDocumentParser
@@ -78,7 +84,7 @@
* @author Arnaud Le Hors, IBM
* @author Andy Clark, IBM
*
- * @version $Id: AbstractXMLDocumentParser.java,v 1.1.2.3 2001/02/26 23:32:19 lehors Exp $
+ * @version $Id: AbstractXMLDocumentParser.java,v 1.1.2.4 2001/03/24 02:45:08 lehors Exp $
*/
public abstract class AbstractXMLDocumentParser
extends XMLParser
@@ -90,6 +96,13 @@
// state
+ /**
+ * True if a parse is in progress. This state is needed because
+ * some features/properties cannot be set while parsing (e.g.
+ * validation and namespaces).
+ */
+ protected boolean fParseInProgress = false;
+
/** True if inside DTD. */
protected boolean fInDTD;
@@ -101,13 +114,47 @@
* Constructs a document parser using the default symbol table
* and grammar pool.
*/
- protected AbstractXMLDocumentParser(ParserConfiguration config) {
+ protected AbstractXMLDocumentParser(XMLParserConfiguration config) {
super(config);
config.setDocumentHandler(this);
config.setDTDHandler(this);
config.setDTDContentModelHandler(this);
- } // <init>(ParserConfiguration)
+ } // <init>(XMLParserConfiguration)
+
+ //
+ // Public methods
+ //
+
+ /**
+ * parse
+ *
+ * @param inputSource
+ *
+ * @exception org.xml.sax.SAXException
+ * @exception java.io.IOException
+ */
+ public void parse(InputSource inputSource)
+ throws SAXException, IOException {
+ try {
+ reset();
+ fConfiguration.parse(inputSource);
+ }
+ catch (SAXException e) {
+ reset();
+ throw e;
+ }
+ catch (IOException e) {
+ reset();
+ throw e;
+ }
+ catch (Exception e) {
+ reset();
+ throw new SAXException(e);
+ }
+
+ } // parse(InputSource)
+
//
// XMLDocumentHandler methods
//
@@ -684,13 +731,11 @@
//
/**
- * reset all components before parsing
+ * reset state
*/
protected void reset() throws SAXException {
- super.reset();
-
+ fParseInProgress = true;
fInDTD = false;
-
} // reset()
} // class AbstractXMLDocumentParser
1.1.2.3 +108 -159 xml-xerces/java/src/org/apache/xerces/parsers/Attic/BasicParserConfiguration.java
Index: BasicParserConfiguration.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/Attic/BasicParserConfiguration.java,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -u -r1.1.2.2 -r1.1.2.3
--- BasicParserConfiguration.java 2001/03/13 19:55:58 1.1.2.2
+++ BasicParserConfiguration.java 2001/03/24 02:45:08 1.1.2.3
@@ -69,11 +69,12 @@
import org.apache.xerces.impl.XMLErrorReporter;
import org.apache.xerces.impl.msg.XMLMessageFormatter;
import org.apache.xerces.util.SymbolTable;
-import org.apache.xerces.xni.XMLComponent;
-import org.apache.xerces.xni.XMLComponentManager;
import org.apache.xerces.xni.XMLDocumentHandler;
import org.apache.xerces.xni.XMLDTDHandler;
import org.apache.xerces.xni.XMLDTDContentModelHandler;
+import org.apache.xerces.xni.parser.XMLComponent;
+import org.apache.xerces.xni.parser.XMLComponentManager;
+import org.apache.xerces.xni.parser.XMLParserConfiguration;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
@@ -107,10 +108,10 @@
* @author Arnaud Le Hors, IBM
* @author Andy Clark, IBM
*
- * @version $Id: BasicParserConfiguration.java,v 1.1.2.2 2001/03/13 19:55:58 lehors Exp $
+ * @version $Id: BasicParserConfiguration.java,v 1.1.2.3 2001/03/24 02:45:08 lehors Exp $
*/
public abstract class BasicParserConfiguration
- extends ParserConfiguration {
+ implements XMLParserConfiguration {
//
// Data
@@ -151,6 +152,42 @@
protected XMLDTDContentModelHandler fDTDContentModelHandler;
+ // constants
+
+ static final String SYMBOL_TABLE = Constants.XERCES_PROPERTY_PREFIX +
+ Constants.SYMBOL_TABLE_PROPERTY;
+ static final String ENTITY_MANAGER =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_MANAGER_PROPERTY;
+ static final String ERROR_REPORTER =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
+ static final String LOCATOR =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.LOCATOR_PROPERTY;
+
+ static final String VALIDATION =
+ Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;
+ static final String NAMESPACES =
+ Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
+ static final String EXTERNAL_GENERAL_ENTITIES =
+ Constants.SAX_FEATURE_PREFIX +
+ Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE;
+ static final String EXTERNAL_PARAMETER_ENTITIES =
+ Constants.SAX_FEATURE_PREFIX +
+ Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE;
+ static final String WARN_ON_DUPLICATE_ATTDEF =
+ Constants.XERCES_FEATURE_PREFIX +
+ Constants.WARN_ON_DUPLICATE_ATTDEF_FEATURE;
+ static final String WARN_ON_UNDECLARED_ELEMDEF =
+ Constants.XERCES_FEATURE_PREFIX +
+ Constants.WARN_ON_UNDECLARED_ELEMDEF_FEATURE;
+ static final String ALLOW_JAVA_ENCODINGS =
+ Constants.XERCES_FEATURE_PREFIX +
+ Constants.ALLOW_JAVA_ENCODINGS_FEATURE;
+ static final String CONTINUE_AFTER_FATAL_ERROR =
+ Constants.XERCES_FEATURE_PREFIX +
+ Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE;
+ static final String LOAD_EXTERNAL_DTD =
+ Constants.XERCES_FEATURE_PREFIX + Constants.LOAD_EXTERNAL_DTD_FEATURE;
+
//
// Constructors
//
@@ -168,23 +205,14 @@
fProperties = new Hashtable();
// set default values for features
- final String VALIDATION = Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;
fFeatures.put(VALIDATION, Boolean.FALSE);
- final String NAMESPACES = Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
fFeatures.put(NAMESPACES, Boolean.TRUE);
- final String EXTERNAL_GENERAL_ENTITIES = Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE;
fFeatures.put(EXTERNAL_GENERAL_ENTITIES, Boolean.TRUE);
- final String EXTERNAL_PARAMETER_ENTITIES = Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE;
fFeatures.put(EXTERNAL_PARAMETER_ENTITIES, Boolean.TRUE);
- final String WARN_ON_DUPLICATE_ATTDEF = Constants.XERCES_FEATURE_PREFIX + Constants.WARN_ON_DUPLICATE_ATTDEF_FEATURE;
fFeatures.put(WARN_ON_DUPLICATE_ATTDEF, Boolean.FALSE);
- final String WARN_ON_UNDECLARED_ELEMDEF = Constants.XERCES_FEATURE_PREFIX + Constants.WARN_ON_UNDECLARED_ELEMDEF_FEATURE;
fFeatures.put(WARN_ON_UNDECLARED_ELEMDEF, Boolean.FALSE);
- final String ALLOW_JAVA_ENCODINGS = Constants.XERCES_FEATURE_PREFIX + Constants.ALLOW_JAVA_ENCODINGS_FEATURE;
fFeatures.put(ALLOW_JAVA_ENCODINGS, Boolean.FALSE);
- final String CONTINUE_AFTER_FATAL_ERROR = Constants.XERCES_FEATURE_PREFIX + Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE;
fFeatures.put(CONTINUE_AFTER_FATAL_ERROR, Boolean.FALSE);
- final String LOAD_EXTERNAL_DTD = Constants.XERCES_FEATURE_PREFIX + Constants.LOAD_EXTERNAL_DTD_FEATURE;
fFeatures.put(LOAD_EXTERNAL_DTD, Boolean.TRUE);
fNeedInitialize = true;
@@ -198,7 +226,6 @@
*/
protected BasicParserConfiguration(SymbolTable symbolTable) {
this();
- final String SYMBOL_TABLE = Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
fSymbolTable = symbolTable;
fProperties.put(SYMBOL_TABLE, fSymbolTable);
} // <init>(SymbolTable)
@@ -213,14 +240,12 @@
protected void initialize() {
// create and register missing components
- final String SYMBOL_TABLE = Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
fSymbolTable = (SymbolTable) fProperties.get(SYMBOL_TABLE);
if (fSymbolTable == null) {
fSymbolTable = new SymbolTable();
fProperties.put(SYMBOL_TABLE, fSymbolTable);
}
- final String ENTITY_MANAGER = Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_MANAGER_PROPERTY;
fEntityManager = (XMLEntityManager) fProperties.get(ENTITY_MANAGER);
if (fEntityManager == null) {
fEntityManager = createEntityManager();
@@ -228,7 +253,6 @@
}
fComponents.addElement(fEntityManager);
- final String ERROR_REPORTER = Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
fErrorReporter = (XMLErrorReporter) fProperties.get(ERROR_REPORTER);
if (fErrorReporter == null) {
fErrorReporter =
@@ -238,6 +262,7 @@
fComponents.addElement(fErrorReporter);
fLocator = (Locator) fEntityManager.getEntityScanner();
+ fProperties.put(LOCATOR, fLocator);
XMLMessageFormatter xmft = new XMLMessageFormatter();
fErrorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);
@@ -258,54 +283,6 @@
// Public methods
//
- /**
- * Parses the input source specified by the given system identifier.
- * <p>
- * This method is equivalent to the following:
- * <pre>
- * parse(new InputSource(systemId));
- * </pre>
- *
- * @param source The input source.
- *
- * @exception org.xml.sax.SAXException Throws exception on SAX error.
- * @exception java.io.IOException Throws exception on i/o error.
- */
- public void parse(String systemId)
- throws SAXException, IOException {
-
- InputSource source = new InputSource(systemId);
- parse(source);
- try {
- Reader reader = source.getCharacterStream();
- if (reader != null) {
- reader.close();
- }
- else {
- InputStream is = source.getByteStream();
- if (is != null) {
- is.close();
- }
- }
- }
- catch (IOException e) {
- // ignore
- }
-
- } // parse(String)
-
- /**
- * parse
- *
- * @param inputSource
- *
- * @exception org.xml.sax.SAXException
- * @exception java.io.IOException
- */
- public abstract void parse(InputSource inputSource)
- throws SAXException, IOException;
-
-
public void setDocumentHandler(XMLDocumentHandler handler) {
fDocumentHandler = handler;
}
@@ -318,74 +295,8 @@
fDTDContentModelHandler = handler;
}
- /**
- * Sets the resolver used to resolve external entities. The EntityResolver
- * interface supports resolution of public and system identifiers.
- *
- * @param resolver The new entity resolver. Passing a null value will
- * uninstall the currently installed resolver.
- */
- public void setEntityResolver(EntityResolver resolver) {
-
- final String ENTITY_RESOLVER = Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;
- fProperties.put(ENTITY_RESOLVER, resolver);
- } // setEntityResolver(EntityResolver)
-
- /**
- * Return the current entity resolver.
- *
- * @return The current entity resolver, or null if none
- * has been registered.
- * @see #setEntityResolver
- */
- public EntityResolver getEntityResolver() {
-
- final String ENTITY_RESOLVER = Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;
- return (EntityResolver)fProperties.get(ENTITY_RESOLVER);
-
- } // getEntityResolver():EntityResolver
-
/**
- * Allow an application to register an error event handler.
- *
- * <p>If the application does not register an error handler, all
- * error events reported by the SAX parser will be silently
- * ignored; however, normal processing may not continue. It is
- * highly recommended that all SAX applications implement an
- * error handler to avoid unexpected bugs.</p>
- *
- * <p>Applications may register a new or different handler in the
- * middle of a parse, and the SAX parser must begin using the new
- * handler immediately.</p>
- *
- * @param errorHandler The error handler.
- * @exception java.lang.NullPointerException If the handler
- * argument is null.
- * @see #getErrorHandler
- */
- public void setErrorHandler(ErrorHandler errorHandler) {
-
- final String ERROR_HANDLER = Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_HANDLER_PROPERTY;
- fProperties.put(ERROR_HANDLER, errorHandler);
-
- } // setErrorHandler(ErrorHandler)
-
- /**
- * Return the current error handler.
- *
- * @return The current error handler, or null if none
- * has been registered.
- * @see #setErrorHandler
- */
- public ErrorHandler getErrorHandler() {
-
- final String ERROR_HANDLER = Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_HANDLER_PROPERTY;
- return (ErrorHandler)fProperties.get(ERROR_HANDLER);
-
- } // getErrorHandler():ErrorHandler
-
- /**
* Set the state of a feature.
*
* Set the state of any feature in a SAX2 parser. The parser
@@ -394,6 +305,7 @@
*
* @param featureId The unique identifier (URI) of the feature.
* @param state The requested state of the feature (true or false).
+ * @param check Whether to check if the feature is recognized.
*
* @exception org.xml.sax.SAXNotRecognizedException If the
* requested feature is not known.
@@ -403,10 +315,12 @@
* @exception org.xml.sax.SAXException If there is any other
* problem fulfilling the request.
*/
- public void setFeature(String featureId, boolean state)
+ public void setFeature(String featureId, boolean state, boolean check)
throws SAXNotRecognizedException, SAXNotSupportedException {
- checkFeature(featureId);
+ if (check) {
+ checkFeature(featureId);
+ }
// forward to every component
int count = fComponents.size();
@@ -417,18 +331,27 @@
// then store the information
fFeatures.put(featureId, state ? Boolean.TRUE : Boolean.FALSE);
- } // setFeature(String,boolean)
+ } // setFeature(String,boolean, boolean)
/**
- * setProperty
+ * Sets the value of a property. This method is called by the parser
+ * and gets propagated to components in this parser configuration.
*
- * @param propertyId
- * @param value
+ * @param propertyId The property identifier.
+ * @param value The value of the property.
+ * @param check Whether to check if the property is recognized.
+ *
+ * @throws SAXNotRecognizedException Thrown if the property is not
+ * recognized by this configuration
+ * or any of its components.
+ * @throws SAXNotSupportedException Thrown if the value is not supported.
*/
- public void setProperty(String propertyId, Object value)
+ public void setProperty(String propertyId, Object value, boolean check)
throws SAXNotRecognizedException, SAXNotSupportedException {
- checkProperty(propertyId);
+ if (check) {
+ checkProperty(propertyId);
+ }
// forward to every component
int count = fComponents.size();
@@ -439,9 +362,52 @@
// then store the information
fProperties.put(propertyId, value);
- } // setProperty(String,Object)
+ } // setProperty(String,Object, boolean)
/**
+ * Returns the state of a feature.
+ *
+ * @param featureId The feature identifier.
+ * @param check Whether to check if the feature is recognized.
+ *
+ * @throws SAXNotRecognizedException Thrown if the feature is not
+ * recognized.
+ * @throws SAXNotSupportedException Thrown if the feature is not
+ * supported.
+ */
+ public boolean getFeature(String featureId, boolean check)
+ throws SAXNotRecognizedException, SAXNotSupportedException {
+
+ if (check) {
+ checkFeature(featureId);
+ }
+ Boolean state = (Boolean) fFeatures.get(featureId);
+ return state.booleanValue();
+
+ } // getFeature(String, boolean):boolean
+
+ /**
+ * Returns the value of a property.
+ *
+ * @param propertyId The property identifier.
+ * @param check Whether to check if the property is recognized.
+ *
+ * @throws SAXNotRecognizedException Thrown if the feature is not
+ * recognized.
+ * @throws SAXNotSupportedException Thrown if the feature is not
+ * supported.
+ */
+ public Object getProperty(String propertyId, boolean check)
+ throws SAXNotRecognizedException, SAXNotSupportedException {
+
+ if (check) {
+ checkProperty(propertyId);
+ }
+ return fProperties.get(propertyId);
+
+ } // getProperty(String, boolean):Object
+
+ /**
* Set the locale to use for messages.
*
* @param locale The locale object to use for localization of messages.
@@ -473,11 +439,8 @@
*/
public boolean getFeature(String featureId)
throws SAXNotRecognizedException, SAXNotSupportedException {
-
- checkFeature(featureId);
- Boolean state = (Boolean) fFeatures.get(featureId);
- return state.booleanValue();
+ return getFeature(featureId, true);
} // getFeature(String):boolean
@@ -493,28 +456,14 @@
*/
public Object getProperty(String propertyId)
throws SAXNotRecognizedException, SAXNotSupportedException {
-
- checkProperty(propertyId);
- return fProperties.get(propertyId);
+ return getProperty(propertyId, true);
} // getProperty(String):Object
public Locator getLocator() {
return fLocator;
} // getLocator():Locator
-
- public SymbolTable getSymbolTable() {
- return fSymbolTable;
- } // getSymbolTable():SymbolTable
-
- public Hashtable getFeatureTable() {
- return fFeatures;
- }
-
- public Hashtable getPropertyTable() {
- return fProperties;
- }
//
// Protected methods
1.19.2.16 +3 -2 xml-xerces/java/src/org/apache/xerces/parsers/DOMParser.java
Index: DOMParser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/DOMParser.java,v
retrieving revision 1.19.2.15
retrieving revision 1.19.2.16
diff -u -r1.19.2.15 -r1.19.2.16
--- DOMParser.java 2001/02/26 23:32:19 1.19.2.15
+++ DOMParser.java 2001/03/24 02:45:08 1.19.2.16
@@ -59,6 +59,7 @@
import org.apache.xerces.impl.validation.GrammarPool;
import org.apache.xerces.util.SymbolTable;
+import org.apache.xerces.xni.parser.XMLParserConfiguration;
/**
* This is the main Xerces DOM parser class. It uses the abstract DOM parser
@@ -69,7 +70,7 @@
* @author Arnaud Le Hors, IBM
* @author Andy Clark, IBM
*
- * @version $Id: DOMParser.java,v 1.19.2.15 2001/02/26 23:32:19 lehors Exp $ */
+ * @version $Id: DOMParser.java,v 1.19.2.16 2001/03/24 02:45:08 lehors Exp $ */
public class DOMParser
extends AbstractDOMParser {
@@ -87,7 +88,7 @@
/**
* Constructs a DOM parser using the specified parser configuration.
*/
- public DOMParser(ParserConfiguration config) {
+ public DOMParser(XMLParserConfiguration config) {
super(config);
} // <init>(ParserConfiguration)
1.12.2.23 +3 -2 xml-xerces/java/src/org/apache/xerces/parsers/SAXParser.java
Index: SAXParser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/SAXParser.java,v
retrieving revision 1.12.2.22
retrieving revision 1.12.2.23
diff -u -r1.12.2.22 -r1.12.2.23
--- SAXParser.java 2001/02/26 23:32:20 1.12.2.22
+++ SAXParser.java 2001/03/24 02:45:09 1.12.2.23
@@ -59,6 +59,7 @@
import org.apache.xerces.impl.validation.GrammarPool;
import org.apache.xerces.util.SymbolTable;
+import org.apache.xerces.xni.parser.XMLParserConfiguration;
/**
* This is the main Xerces SAX parser class. It uses the abstract SAX parser
@@ -69,7 +70,7 @@
* @author Arnaud Le Hors, IBM
* @author Andy Clark, IBM
*
- * @version $Id: SAXParser.java,v 1.12.2.22 2001/02/26 23:32:20 lehors Exp $ */
+ * @version $Id: SAXParser.java,v 1.12.2.23 2001/03/24 02:45:09 lehors Exp $ */
public class SAXParser
extends AbstractSAXParser {
@@ -87,7 +88,7 @@
/**
* Constructs a SAX parser using the specified parser configuration.
*/
- public SAXParser(ParserConfiguration config) {
+ public SAXParser(XMLParserConfiguration config) {
super(config);
} // <init>(ParserConfiguration)
1.1.2.4 +16 -7 xml-xerces/java/src/org/apache/xerces/parsers/Attic/StandardParserConfiguration.java
Index: StandardParserConfiguration.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/Attic/StandardParserConfiguration.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -r1.1.2.3 -r1.1.2.4
--- StandardParserConfiguration.java 2001/03/19 23:34:40 1.1.2.3
+++ StandardParserConfiguration.java 2001/03/24 02:45:09 1.1.2.4
@@ -84,7 +84,7 @@
* @author Arnaud Le Hors, IBM
* @author Andy Clark, IBM
*
- * @version $Id: StandardParserConfiguration.java,v 1.1.2.3 2001/03/19 23:34:40 lehors Exp $ */
+ * @version $Id: StandardParserConfiguration.java,v 1.1.2.4 2001/03/24 02:45:09 lehors Exp $ */
public class StandardParserConfiguration
extends BasicParserConfiguration {
@@ -129,6 +129,21 @@
*/
protected boolean fParseInProgress = false;
+ // constants
+
+ static final String GRAMMAR_POOL =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.GRAMMAR_POOL_PROPERTY;
+ static final String DOCUMENT_SCANNER =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.DOCUMENT_SCANNER_PROPERTY;
+ static final String DTD_SCANNER =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_SCANNER_PROPERTY;
+ static final String VALIDATOR =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATOR_PROPERTY;
+ static final String DATATYPE_VALIDATOR_FACTORY =
+ Constants.XERCES_PROPERTY_PREFIX +
+ Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY;
+
+
//
// Constructors
//
@@ -155,7 +170,6 @@
GrammarPool grammarPool) {
super(symbolTable);
- final String GRAMMAR_POOL = Constants.XERCES_PROPERTY_PREFIX + Constants.GRAMMAR_POOL_PROPERTY;
fGrammarPool = grammarPool;
fProperties.put(GRAMMAR_POOL, fGrammarPool);
}
@@ -171,14 +185,12 @@
super.initialize();
// create and register missing components
- final String GRAMMAR_POOL = Constants.XERCES_PROPERTY_PREFIX + Constants.GRAMMAR_POOL_PROPERTY;
fGrammarPool = (GrammarPool) fProperties.get(GRAMMAR_POOL);
if (fGrammarPool == null) {
fGrammarPool = new GrammarPool();
fProperties.put(GRAMMAR_POOL, fGrammarPool);
}
- final String DOCUMENT_SCANNER = Constants.XERCES_PROPERTY_PREFIX + Constants.DOCUMENT_SCANNER_PROPERTY;
fScanner = (XMLDocumentScanner) fProperties.get(DOCUMENT_SCANNER);
if (fScanner == null) {
fScanner = createDocumentScanner();
@@ -186,7 +198,6 @@
}
fComponents.addElement(fScanner);
- final String DTD_SCANNER = Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_SCANNER_PROPERTY;
fDTDScanner = (XMLDTDScanner) fProperties.get(DTD_SCANNER);
if (fDTDScanner == null) {
fDTDScanner = createDTDScanner();
@@ -194,7 +205,6 @@
}
fComponents.addElement(fDTDScanner);
- final String VALIDATOR = Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATOR_PROPERTY;
fValidator = (XMLValidator) fProperties.get(VALIDATOR);
if (fValidator == null) {
fValidator = createValidator();
@@ -202,7 +212,6 @@
}
fComponents.addElement(fValidator);
- final String DATATYPE_VALIDATOR_FACTORY = Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY;
fDatatypeValidatorFactory = (DatatypeValidatorFactory)
fProperties.get(DATATYPE_VALIDATOR_FACTORY);
if (fDatatypeValidatorFactory == null) {
1.1.2.37 +3 -2 xml-xerces/java/src/org/apache/xerces/parsers/Attic/XMLDocumentParser.java
Index: XMLDocumentParser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/Attic/XMLDocumentParser.java,v
retrieving revision 1.1.2.36
retrieving revision 1.1.2.37
diff -u -r1.1.2.36 -r1.1.2.37
--- XMLDocumentParser.java 2001/02/26 23:32:20 1.1.2.36
+++ XMLDocumentParser.java 2001/03/24 02:45:09 1.1.2.37
@@ -59,6 +59,7 @@
import org.apache.xerces.impl.validation.GrammarPool;
import org.apache.xerces.util.SymbolTable;
+import org.apache.xerces.xni.parser.XMLParserConfiguration;
/**
* This is a concrete vanilla XML parser class. It uses the abstract parser
@@ -69,7 +70,7 @@
* @author Arnaud Le Hors, IBM
* @author Andy Clark, IBM
*
- * @version $Id: XMLDocumentParser.java,v 1.1.2.36 2001/02/26 23:32:20 lehors Exp $ */
+ * @version $Id: XMLDocumentParser.java,v 1.1.2.37 2001/03/24 02:45:09 lehors Exp $ */
public class XMLDocumentParser
extends AbstractXMLDocumentParser {
@@ -88,7 +89,7 @@
/**
* Constructs a document parser using the specified parser configuration.
*/
- public XMLDocumentParser(ParserConfiguration config) {
+ public XMLDocumentParser(XMLParserConfiguration config) {
super(config);
} // <init>(ParserConfiguration)
1.1.2.9 +2 -32 xml-xerces/java/src/org/apache/xerces/parsers/Attic/XMLGrammarParser.java
Index: XMLGrammarParser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/Attic/XMLGrammarParser.java,v
retrieving revision 1.1.2.8
retrieving revision 1.1.2.9
diff -u -r1.1.2.8 -r1.1.2.9
--- XMLGrammarParser.java 2001/02/26 23:32:20 1.1.2.8
+++ XMLGrammarParser.java 2001/03/24 02:45:09 1.1.2.9
@@ -57,7 +57,6 @@
package org.apache.xerces.parsers;
-import org.apache.xerces.xni.XMLComponentManager;
import org.apache.xerces.util.SymbolTable;
import org.apache.xerces.impl.validation.DatatypeValidatorFactory;
import org.xml.sax.SAXNotRecognizedException;
@@ -65,11 +64,10 @@
/**
* @author Stubs generated by DesignDoc on Mon Sep 11 11:10:57 PDT 2000
- * @version $Id: XMLGrammarParser.java,v 1.1.2.8 2001/02/26 23:32:20 lehors Exp $
+ * @version $Id: XMLGrammarParser.java,v 1.1.2.9 2001/03/24 02:45:09 lehors Exp $
*/
public abstract class XMLGrammarParser
- extends XMLParser
- implements XMLComponentManager {
+ extends XMLParser {
//
// Data
@@ -90,33 +88,5 @@
protected XMLGrammarParser(SymbolTable symbolTable) {
super(new StandardParserConfiguration(symbolTable));
}
-
- //
- // XMLComponentManager methods
- //
-
- /**
- * getFeature
- *
- * @param featureId
- *
- * @return
- */
- public boolean getFeature(String featureId)
- throws SAXNotRecognizedException, SAXNotSupportedException {
- return false;
- } // getFeature
-
- /**
- * getProperty
- *
- * @param propertyId
- *
- * @return
- */
- public Object getProperty(String propertyId)
- throws SAXNotRecognizedException, SAXNotSupportedException {
- return null;
- } // getProperty
} // class XMLGrammarParser
1.1.2.23 +62 -30 xml-xerces/java/src/org/apache/xerces/parsers/Attic/XMLParser.java
Index: XMLParser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/Attic/XMLParser.java,v
retrieving revision 1.1.2.22
retrieving revision 1.1.2.23
diff -u -r1.1.2.22 -r1.1.2.23
--- XMLParser.java 2001/02/26 23:32:20 1.1.2.22
+++ XMLParser.java 2001/03/24 02:45:09 1.1.2.23
@@ -60,6 +60,9 @@
import java.io.IOException;
import java.util.Locale;
+import org.apache.xerces.xni.parser.XMLParserConfiguration;
+import org.apache.xerces.impl.Constants;
+
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
@@ -74,16 +77,25 @@
* @author Arnaud Le Hors, IBM
* @author Andy Clark, IBM
*
- * @version $Id: XMLParser.java,v 1.1.2.22 2001/02/26 23:32:20 lehors Exp $
+ * @version $Id: XMLParser.java,v 1.1.2.23 2001/03/24 02:45:09 lehors Exp $
*/
public abstract class XMLParser {
//
// Data
//
+
+ XMLParserConfiguration fConfiguration;
- ParserConfiguration fConfiguration;
+ // constants
+ static final String ENTITY_RESOLVER =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;
+ static final String ERROR_REPORTER =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
+ static final String ERROR_HANDLER =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_HANDLER_PROPERTY;
+
//
// Constructors
//
@@ -91,11 +103,11 @@
/**
* Default Constructor.
*/
- protected XMLParser(ParserConfiguration config) {
+ protected XMLParser(XMLParserConfiguration config) {
fConfiguration = config;
- } // <init>(ParserConfiguration)
+ } // <init>(XMLParserConfiguration)
//
// Public methods
@@ -117,7 +129,8 @@
public void parse(String systemId)
throws SAXException, IOException {
- fConfiguration.parse(systemId);
+ InputSource source = new InputSource(systemId);
+ fConfiguration.parse(source);
} // parse(String)
@@ -145,7 +158,15 @@
*/
public void setEntityResolver(EntityResolver resolver) {
- fConfiguration.setEntityResolver(resolver);
+ try {
+ fConfiguration.setProperty(ENTITY_RESOLVER, resolver, false);
+ }
+ catch (SAXNotSupportedException e) {
+ // shouldn't happen...
+ }
+ catch (SAXNotRecognizedException e) {
+ // shouldn't happen...
+ }
} // setEntityResolver(EntityResolver)
@@ -158,7 +179,17 @@
*/
public EntityResolver getEntityResolver() {
- return fConfiguration.getEntityResolver();
+ try {
+ return (EntityResolver)fConfiguration.getProperty(ENTITY_RESOLVER,
+ false);
+ }
+ catch (SAXNotSupportedException e) {
+ // shouldn't happen...
+ }
+ catch (SAXNotRecognizedException e) {
+ // shouldn't happen...
+ }
+ return null;
} // getEntityResolver():EntityResolver
@@ -182,7 +213,15 @@
*/
public void setErrorHandler(ErrorHandler errorHandler) {
- fConfiguration.setErrorHandler(errorHandler);
+ try {
+ fConfiguration.setProperty(ERROR_HANDLER, errorHandler, false);
+ }
+ catch (SAXNotSupportedException e) {
+ // shouldn't happen...
+ }
+ catch (SAXNotRecognizedException e) {
+ // shouldn't happen...
+ }
} // setErrorHandler(ErrorHandler)
@@ -195,7 +234,17 @@
*/
public ErrorHandler getErrorHandler() {
- return fConfiguration.getErrorHandler();
+ try {
+ return (ErrorHandler) fConfiguration.getProperty(ERROR_HANDLER,
+ false);
+ }
+ catch (SAXNotSupportedException e) {
+ // shouldn't happen...
+ }
+ catch (SAXNotRecognizedException e) {
+ // shouldn't happen...
+ }
+ return null;
} // getErrorHandler():ErrorHandler
@@ -220,7 +269,7 @@
public void setFeature(String featureId, boolean state)
throws SAXNotRecognizedException, SAXNotSupportedException {
- fConfiguration.setFeature(featureId, state);
+ fConfiguration.setFeature(featureId, state, true);
} // setFeature(String,boolean)
@@ -233,7 +282,7 @@
public void setProperty(String propertyId, Object value)
throws SAXNotRecognizedException, SAXNotSupportedException {
- fConfiguration.setProperty(propertyId, value);
+ fConfiguration.setProperty(propertyId, value, true);
} // setProperty(String,Object)
@@ -253,10 +302,6 @@
} // setLocale(Locale)
- //
- // XMLComponentManager methods
- //
-
/**
* Returns the state of a feature.
*
@@ -270,7 +315,7 @@
public boolean getFeature(String featureId)
throws SAXNotRecognizedException, SAXNotSupportedException {
- return fConfiguration.getFeature(featureId);
+ return fConfiguration.getFeature(featureId, true);
} // getFeature(String):boolean
@@ -287,21 +332,8 @@
public Object getProperty(String propertyId)
throws SAXNotRecognizedException, SAXNotSupportedException {
- return fConfiguration.getProperty(propertyId);
+ return fConfiguration.getProperty(propertyId, true);
} // getProperty(String):Object
-
- //
- // Protected methods
- //
-
- /**
- * reset all components before parsing
- */
- protected void reset() throws SAXException {
-
- fConfiguration.reset();
-
- } // reset()
} // class XMLParser
No revision
No revision
1.1.2.2 +3 -3 xml-xerces/java/src/org/apache/xerces/xni/parser/Attic/XMLComponent.java
Index: XMLComponent.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/xni/parser/Attic/XMLComponent.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- XMLComponent.java 2001/03/23 08:45:29 1.1.2.1
+++ XMLComponent.java 2001/03/24 02:45:10 1.1.2.2
@@ -72,7 +72,7 @@
* @author Stubs generated by DesignDoc on Mon Sep 11 11:10:57 PDT 2000
* @author Andy Clark, IBM
*
- * @version $Id: XMLComponent.java,v 1.1.2.1 2001/03/23 08:45:29 andyc Exp $
+ * @version $Id: XMLComponent.java,v 1.1.2.2 2001/03/24 02:45:10 lehors Exp $
*/
public interface XMLComponent {
@@ -134,9 +134,9 @@
throws SAXNotRecognizedException, SAXNotSupportedException;
/** Returns the set of features that this component recognizes. */
- public String[] getRecognizedFeatures();
+ // public String[] getRecognizedFeatures();
/** Returns the set of properties that this component recognizes. */
- public String[] getRecognizedProperties();
+ // public String[] getRecognizedProperties();
} // interface XMLComponent
1.1.2.2 +46 -3 xml-xerces/java/src/org/apache/xerces/xni/parser/Attic/XMLParserConfiguration.java
Index: XMLParserConfiguration.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/xni/parser/Attic/XMLParserConfiguration.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- XMLParserConfiguration.java 2001/03/23 08:45:30 1.1.2.1
+++ XMLParserConfiguration.java 2001/03/24 02:45:10 1.1.2.2
@@ -58,6 +58,7 @@
package org.apache.xerces.xni.parser;
import java.io.IOException;
+import java.util.Locale;
import org.apache.xerces.xni.XMLDocumentHandler;
import org.apache.xerces.xni.XMLDTDHandler;
@@ -115,7 +116,7 @@
* @author Arnaud Le Hors, IBM
* @author Andy Clark, IBM
*
- * @version $Id: XMLParserConfiguration.java,v 1.1.2.1 2001/03/23 08:45:30 andyc Exp $
+ * @version $Id: XMLParserConfiguration.java,v 1.1.2.2 2001/03/24 02:45:10 lehors Exp $
*/
public interface XMLParserConfiguration
extends XMLComponentManager {
@@ -157,13 +158,14 @@
*
* @param featureId The feature identifier.
* @param state The state of the feature.
+ * @param check Whether to check if the feature is recognized.
*
* @throws SAXNotRecognizedException Thrown if the feature is not
* recognized by this configuration
* or any of its components.
* @throws SAXNotSupportedException Thrown if the state is not supported.
*/
- public void setFeature(String featureId, boolean state)
+ public void setFeature(String featureId, boolean state, boolean check)
throws SAXNotRecognizedException, SAXNotSupportedException;
/**
@@ -172,16 +174,45 @@
*
* @param propertyId The property identifier.
* @param value The value of the property.
+ * @param check Whether to check if the property is recognized.
*
* @throws SAXNotRecognizedException Thrown if the property is not
* recognized by this configuration
* or any of its components.
* @throws SAXNotSupportedException Thrown if the value is not supported.
*/
- public void setProperty(String propertyId, Object value)
+ public void setProperty(String propertyId, Object value, boolean check)
throws SAXNotRecognizedException, SAXNotSupportedException;
/**
+ * Returns the state of a feature.
+ *
+ * @param featureId The feature identifier.
+ * @param check Whether to check if the feature is recognized.
+ *
+ * @throws SAXNotRecognizedException Thrown if the feature is not
+ * recognized.
+ * @throws SAXNotSupportedException Thrown if the feature is not
+ * supported.
+ */
+ public boolean getFeature(String featureId, boolean check)
+ throws SAXNotRecognizedException, SAXNotSupportedException;
+
+ /**
+ * Returns the value of a property.
+ *
+ * @param propertyId The property identifier.
+ * @param check Whether to check if the property is recognized.
+ *
+ * @throws SAXNotRecognizedException Thrown if the feature is not
+ * recognized.
+ * @throws SAXNotSupportedException Thrown if the feature is not
+ * supported.
+ */
+ public Object getProperty(String propertyId, boolean check)
+ throws SAXNotRecognizedException, SAXNotSupportedException;
+
+ /**
* Sets the document handler to receive information about the document.
*
* @param documentHandler The document handler.
@@ -206,5 +237,17 @@
* @param dtdContentModelHandler The DTD content model handler.
*/
public void setDTDContentModelHandler(XMLDTDContentModelHandler dtdContentModelHandler);
+
+ /**
+ * Set the locale to use for messages.
+ *
+ * @param locale The locale object to use for localization of messages.
+ *
+ * @exception SAXException An exception thrown if the parser does not
+ * support the specified locale.
+ *
+ * @see org.xml.sax.Parser
+ */
+ public void setLocale(Locale locale) throws SAXException;
} // interface ParserConfiguration
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org
Re: setFeature/Property (was Re: cvs commit:
xml-xerces/java/src/org/apache/xerces/xni/parser XMLComponent.java
XMLParserConfiguration.java)
Posted by Andy Clark <an...@apache.org>.
Ted Leung wrote:
> So let me make sure I get it. We have to re-setup the pipeline every time
> we call parse() right? How is this going to interact with doing stuff like
> reset() on an existing parser? Will we still have to setup the pipeline
> between resets?
Only if the nature of the pipeline is dynamic in the sense
that we don't know what components will be used at creation
time (before setting features/properties and parsing). Even
if the pipeline is created dynamically (via an XML config
file, for example) this is ok as long as it's done before-
hand and isn't changed.
--
Andy Clark * IBM, TRL - Japan * andyc@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: setFeature/Property (was Re: cvs commit: xml-xerces/java/src/org/apache/xerces/xni/parser XMLComponent.java XMLParserConfiguration.java)
Posted by Ted Leung <tw...@sauria.com>.
----- Original Message -----
From: "Arnaud Le Hors" <le...@us.ibm.com>
To: <xe...@xml.apache.org>
Sent: Tuesday, March 27, 2001 12:30 PM
Subject: setFeature/Property (was Re: cvs commit:
xml-xerces/java/src/org/apache/xerces/xni/parser XMLComponent.java
XMLParserConfiguration.java)
> Andy Clark wrote:
> >
> > Okay, thanks for the clarification. I just sort of freaked when
> > all these changes were made without much reasoning behind it. I
> > feel much better now. :)
>
> The fact you don't know the reasoning behind a change doesn't
> necessarily means there is none. :) I can see how much you trust me
> now... ;)
>
> > > SAXParser:
> > >
> > > check for SAX feature
> > > if known process and send it to the config
> > > else simply forward to the config
> >
> > Okay, so we have the situation where specific parser configs
> > such as DOM or SAX add recognized features to the parser config
> > but the parser is not a component. And if it were, then we have
> > the recursion problem you mentioned.
>
> That's a good summary.
>
> > Simple solution. Add the following methods to the parser
> > configuration:
> >
> > public void addRecognizedFeature(String featureId);
> > public void addRecognizedProperty(String propertyId);
>
> Hmm. If that's what it is then I'd rather make them:
>
> public void addRecognizedFeatures(String[] featureIds);
> public void addRecognizedProperties(String[] propertyIds);
>
> > Then the parser can add the features and properties that it
> > needs to recognize; everything is forwarded to and is managed
> > by the configuration; and you avoid the recursion. Does this
> > solve the problems we're facing? Or are there more?
>
> Kinda. It does solve the problem but it's not optimal. It means that
> even though the SAXParser already recognized the feature/property the
> configuration is going to check on it. My check flag avoids this. But
> I'll admit that this is probably not an area where performance really
> matters.
>
> One other problem with this config stuff (not your proposal) is that to
> allow an application to register its own components through the
> properties (to use instead of the default ones) I have to delay the
> creation of the pipeline until parse() gets called. As opposed to doing
> it at creation time. But this means the configuration object can't
> forward to the components the features and properties that are set
> before calling parse(). I don't have any components yet! Any ideas?
So let me make sure I get it. We have to re-setup the pipeline every time
we call parse() right? How is this going to interact with doing stuff like
reset() on an existing parser? Will we still have to setup the pipeline
between
resets?
Ted
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: setFeature/Property (was Re: cvs commit:
xml-xerces/java/src/org/apache/xerces/xni/parser XMLComponent.java
XMLParserConfiguration.java)
Posted by Andy Clark <an...@apache.org>.
Arnaud Le Hors wrote:
> > public void addRecognizedFeature(String featureId);
> > public void addRecognizedProperty(String propertyId);
>
> Hmm. If that's what it is then I'd rather make them:
>
> public void addRecognizedFeatures(String[] featureIds);
> public void addRecognizedProperties(String[] propertyIds);
Fine. One call is better than many.
> One other problem with this config stuff (not your proposal) is that to
> allow an application to register its own components through the
> properties (to use instead of the default ones) I have to delay the
> creation of the pipeline until parse() gets called. As opposed to doing
Is it a reasonable scenario that the parser configuration
will actually change from parse to parse? I would prefer if
people were forced to create a new configured parser instance
if they want a different configuration for a new parse.
Or, in the case where the pipeline is reconfigured based
on application settings, then the behavior is undefined (as
well it should be).
--
Andy Clark * IBM, TRL - Japan * andyc@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
setFeature/Property (was Re: cvs commit:
xml-xerces/java/src/org/apache/xerces/xni/parser XMLComponent.java
XMLParserConfiguration.java)
Posted by Arnaud Le Hors <le...@us.ibm.com>.
Andy Clark wrote:
>
> Okay, thanks for the clarification. I just sort of freaked when
> all these changes were made without much reasoning behind it. I
> feel much better now. :)
The fact you don't know the reasoning behind a change doesn't
necessarily means there is none. :) I can see how much you trust me
now... ;)
> > SAXParser:
> >
> > check for SAX feature
> > if known process and send it to the config
> > else simply forward to the config
>
> Okay, so we have the situation where specific parser configs
> such as DOM or SAX add recognized features to the parser config
> but the parser is not a component. And if it were, then we have
> the recursion problem you mentioned.
That's a good summary.
> Simple solution. Add the following methods to the parser
> configuration:
>
> public void addRecognizedFeature(String featureId);
> public void addRecognizedProperty(String propertyId);
Hmm. If that's what it is then I'd rather make them:
public void addRecognizedFeatures(String[] featureIds);
public void addRecognizedProperties(String[] propertyIds);
> Then the parser can add the features and properties that it
> needs to recognize; everything is forwarded to and is managed
> by the configuration; and you avoid the recursion. Does this
> solve the problems we're facing? Or are there more?
Kinda. It does solve the problem but it's not optimal. It means that
even though the SAXParser already recognized the feature/property the
configuration is going to check on it. My check flag avoids this. But
I'll admit that this is probably not an area where performance really
matters.
One other problem with this config stuff (not your proposal) is that to
allow an application to register its own components through the
properties (to use instead of the default ones) I have to delay the
creation of the pipeline until parse() gets called. As opposed to doing
it at creation time. But this means the configuration object can't
forward to the components the features and properties that are set
before calling parse(). I don't have any components yet! Any ideas?
--
Arnaud Le Hors - IBM Cupertino, XML Strategy Group
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: cvs commit: xml-xerces/java/src/org/apache/xerces/xni/parser
XMLComponent.java XMLParserConfiguration.java
Posted by Andy Clark <an...@apache.org>.
Arnaud Le Hors wrote:
> I checked that in friday night before leaving the office and didn't have
> to time to explain. We have a problem that I'm not sure how to address.
> Let me get to it now.
Okay, thanks for the clarification. I just sort of freaked when
all these changes were made without much reasoning behind it. I
feel much better now. :)
> SAXParser:
>
> check for SAX feature
> if known process and send it to the config
> else simply forward to the config
Okay, so we have the situation where specific parser configs
such as DOM or SAX add recognized features to the parser config
but the parser is not a component. And if it were, then we have
the recursion problem you mentioned.
Simple solution. Add the following methods to the parser
configuration:
public void addRecognizedFeature(String featureId);
public void addRecognizedProperty(String propertyId);
Then the parser can add the features and properties that it
needs to recognize; everything is forwarded to and is managed
by the configuration; and you avoid the recursion. Does this
solve the problems we're facing? Or are there more?
--
Andy Clark * IBM, TRL - Japan * andyc@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: cvs commit: xml-xerces/java/src/org/apache/xerces/xni/parser
XMLComponent.java XMLParserConfiguration.java
Posted by Arnaud Le Hors <le...@us.ibm.com>.
All right,
I checked that in friday night before leaving the office and didn't have
to time to explain. We have a problem that I'm not sure how to address.
Let me get to it now.
> > + * @param check Whether to check if the feature is recognized.
> > [...]
> > - public void setFeature(String featureId, boolean state)
> > + public void setFeature(String featureId, boolean state, boolean check)
> > throws SAXNotRecognizedException, SAXNotSupportedException;
>
> A "check" parameter? Yuck. First of all, this isn't needed
> because the parser configuration knows all of the recognized
> features/properties from the getRecognizedFeatures/Properties
> methods, respectively.
Not true. The problem that the parser is not a component, I wanted to
make it one and you said 'no way, it's not a component it's the parser'.
Because of that the configuration does NOT know what features and
properties the parser recognizes/supports.
Practically speaking that means I have to do something like that for
setFeature:
SAXParser:
check for SAX feature
if known process and send it to the config
else simply forward to the config
Because the config doesn't know about the SAX feature when the parser
sends it one we need the config not to check on it but simply store the
value and forward it to every component. That's what this extra set of
methods is about.
If we make the parser a component. Then the config can query the parser
for what feature/property it recognizes. But unfortunately it doesn't
save us from needing an extra set of methods. Because we'd have
something like that:
SAXParser:
forward setfeature to config
Config:
forward setfeature to every component (including SAXParser)
This leads to an infinite loop unless you use distinct methods!
> Just because you haven't implemented
> those methods yet on the parser components, doesn't mean
> that we need this extra parameter.
On the contrary!! Because I haven't implemeted those methods yet means I
DO need this extra parameter. Just a fact! :-)
> Second, adding this
> parameter breaks the API compatibility with the equivalent
> methods in SAX2's XMLReader interface. I'd like them to
> overlay each other.
It doesn't break anything. The SAX methods are there ALSO.
> > /**
> > + * Returns the state of a feature.
> > + *
> > + * @param featureId The feature identifier.
> > + * @param check Whether to check if the feature is recognized.
> > + *
> > + * @throws SAXNotRecognizedException Thrown if the feature is not
> > + * recognized.
> > + * @throws SAXNotSupportedException Thrown if the feature is not
> > + * supported.
> > + */
> > + public boolean getFeature(String featureId, boolean check)
> > + throws SAXNotRecognizedException, SAXNotSupportedException;
>
> The getFeature/Property method prototypes don't need to be
> explicitly added to the XMLParserConfiguration interface
> because they are already defined on XMLComponentManager,
> which the parser configuration interface extends.
But, as you noticed, there are NOT the same, these have an extra
parameter. :-)
--
Arnaud Le Hors - IBM Cupertino, XML Strategy Group
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: cvs commit: xml-xerces/java/src/org/apache/xerces/xni/parser
XMLComponent.java XMLParserConfiguration.java
Posted by Andy Clark <an...@apache.org>.
lehors@apache.org wrote:
> + * @param check Whether to check if the feature is recognized.
> [...]
> - public void setFeature(String featureId, boolean state)
> + public void setFeature(String featureId, boolean state, boolean check)
> throws SAXNotRecognizedException, SAXNotSupportedException;
A "check" parameter? Yuck. First of all, this isn't needed
because the parser configuration knows all of the recognized
features/properties from the getRecognizedFeatures/Properties
methods, respectively. Just because you haven't implemented
those methods yet on the parser components, doesn't mean
that we need this extra parameter. Second, adding this
parameter breaks the API compatibility with the equivalent
methods in SAX2's XMLReader interface. I'd like them to
overlay each other.
> /**
> + * Returns the state of a feature.
> + *
> + * @param featureId The feature identifier.
> + * @param check Whether to check if the feature is recognized.
> + *
> + * @throws SAXNotRecognizedException Thrown if the feature is not
> + * recognized.
> + * @throws SAXNotSupportedException Thrown if the feature is not
> + * supported.
> + */
> + public boolean getFeature(String featureId, boolean check)
> + throws SAXNotRecognizedException, SAXNotSupportedException;
The getFeature/Property method prototypes don't need to be
explicitly added to the XMLParserConfiguration interface
because they are already defined on XMLComponentManager,
which the parser configuration interface extends.
--
Andy Clark * IBM, TRL - Japan * andyc@apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org