You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by el...@apache.org on 2002/09/16 23:36:41 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/parsers BasicParserConfiguration.java DOMParser.java SAXParser.java
elena 2002/09/16 14:36:41
Modified: java/src/org/apache/xerces/impl Constants.java
XMLDocumentScannerImpl.java
XMLNSDocumentScannerImpl.java
XMLNamespaceBinder.java
java/src/org/apache/xerces/impl/dtd XMLDTDValidator.java
XMLNSDTDValidator.java
java/src/org/apache/xerces/impl/xs XMLSchemaValidator.java
java/src/org/apache/xerces/impl/xs/dom DOMParser.java
java/src/org/apache/xerces/parsers
BasicParserConfiguration.java DOMParser.java
SAXParser.java
Log:
Add new internal property: namespace-context that represent a shared namespace
context between all the components. This property is reset by a configuration just before
parse and is queried by all components.
Note: this property MUST be set by the configuration.
The private copies of the namespace support are removed.
Revision Changes Path
1.20 +3 -1 xml-xerces/java/src/org/apache/xerces/impl/Constants.java
Index: Constants.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/Constants.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- Constants.java 23 Aug 2002 20:38:26 -0000 1.19
+++ Constants.java 16 Sep 2002 21:36:40 -0000 1.20
@@ -303,6 +303,8 @@
/** Validation manager property ("internal/validation-manager"). */
public static final String VALIDATION_MANAGER_PROPERTY = "internal/validation-manager";
+ /** Validation manager property ("internal/namespace-context"). */
+ public static final String NAMESPACE_CONTEXT_PROPERTY = "internal/namespace-context";
// general constants
1.23 +6 -1 xml-xerces/java/src/org/apache/xerces/impl/XMLDocumentScannerImpl.java
Index: XMLDocumentScannerImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLDocumentScannerImpl.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- XMLDocumentScannerImpl.java 12 Sep 2002 21:56:56 -0000 1.22
+++ XMLDocumentScannerImpl.java 16 Sep 2002 21:36:40 -0000 1.23
@@ -155,6 +155,10 @@
protected static final String VALIDATION_MANAGER =
Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATION_MANAGER_PROPERTY;
+ /** Internal property: namespace context */
+ protected static final String NAMESPACE_CONTEXT_PROPERTY =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.NAMESPACE_CONTEXT_PROPERTY;
+
// recognized features and properties
/** Recognized features. */
@@ -173,6 +177,7 @@
ENTITY_MANAGER,
DTD_SCANNER,
VALIDATION_MANAGER,
+ NAMESPACE_CONTEXT_PROPERTY
};
//
1.3 +23 -21 xml-xerces/java/src/org/apache/xerces/impl/XMLNSDocumentScannerImpl.java
Index: XMLNSDocumentScannerImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLNSDocumentScannerImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XMLNSDocumentScannerImpl.java 16 Sep 2002 17:54:39 -0000 1.2
+++ XMLNSDocumentScannerImpl.java 16 Sep 2002 21:36:40 -0000 1.3
@@ -112,15 +112,15 @@
extends XMLDocumentScannerImpl {
/** If is true, the dtd validator is no longer in the pipeline
- * and the scanner should bind namespaces */
- protected boolean fBindNamespaces;
-
+ * and the scanner should bind namespaces */
+ protected boolean fBindNamespaces;
+
/** If validating parser, make sure we report an error in the
- * scanner if DTD grammar is missing.*/
+ * scanner if DTD grammar is missing.*/
protected boolean fPerformValidation;
-
+
/** Namespace support. */
- protected NamespaceSupport fNamespaceSupport = new NamespaceSupport();
+ protected NamespaceSupport fNamespaceSupport = null;
protected String[] fUri= new String[4];
protected String[] fLocalpart = new String[4];
protected int fLength = 0;
@@ -217,7 +217,8 @@
if (c == '>') {
fEntityScanner.scanChar();
break;
- } else if (c == '/') {
+ }
+ else if (c == '/') {
fEntityScanner.scanChar();
if (!fEntityScanner.skipChar('>')) {
reportFatalError("ElementUnterminated",
@@ -225,7 +226,8 @@
}
empty = true;
break;
- } else if (!XMLChar.isNameStart(c) || !sawSpace) {
+ }
+ else if (!XMLChar.isNameStart(c) || !sawSpace) {
reportFatalError("ElementUnterminated", new Object[]{rawname});
}
@@ -416,8 +418,8 @@
+ // record namespace declarations if any.
if (fBindNamespaces) {
- // get namespace declarations
String localpart = fAttributeQName.localpart;
String prefix = fAttributeQName.prefix != null
@@ -486,20 +488,15 @@
if (fDocumentHandler != null) {
fDocumentHandler.startPrefixMapping(prefix, uri, null);
}
- } else {
-
+ }
+ else {
// attempt to bind attribute
if (fAttributeQName.prefix != null) {
attributes.setURI(oldLen, fNamespaceSupport.getURI(fAttributeQName.prefix));
}
}
-
}
-
-
-
-
if (DEBUG_CONTENT_SCANNING) System.out.println("<<< scanAttribute()");
} // scanAttribute(XMLAttributes)
@@ -557,6 +554,8 @@
// call handler
if (fDocumentHandler != null ) {
+
+ fDocumentHandler.endElement(fElementQName, null);
if (fBindNamespaces) {
int count = fNamespaceSupport.getDeclaredPrefixCount();
for (int i = count - 1; i >= 0; i--) {
@@ -566,7 +565,6 @@
fNamespaceSupport.popContext();
}
- fDocumentHandler.endElement(fElementQName, null);
}
return fMarkupDepth;
@@ -580,8 +578,9 @@
super.reset(componentManager);
fPerformValidation = false;
fBindNamespaces = false;
- fNamespaceSupport.reset();
+ // internal xerces property: namespace context
+ fNamespaceSupport = (NamespaceSupport)componentManager.getProperty(NAMESPACE_CONTEXT_PROPERTY);
}
/** Creates a content dispatcher. */
@@ -609,8 +608,11 @@
*/
protected boolean scanRootElementHook()
throws IOException, XNIException {
- if (fDTDValidator != null && !fDTDValidator.hasGrammar()) {
- fBindNamespaces = true;
+ if (fDTDValidator == null) {
+ fBindNamespaces = true;
+ }
+ else if (!fDTDValidator.hasGrammar()) {
+ fBindNamespaces = true;
fPerformValidation = fDTDValidator.validate();
// re-configure pipeline
//
1.22 +7 -2 xml-xerces/java/src/org/apache/xerces/impl/XMLNamespaceBinder.java
Index: XMLNamespaceBinder.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLNamespaceBinder.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- XMLNamespaceBinder.java 16 Aug 2002 18:08:37 -0000 1.21
+++ XMLNamespaceBinder.java 16 Sep 2002 21:36:40 -0000 1.22
@@ -122,6 +122,10 @@
protected static final String ERROR_REPORTER =
Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
+ /** Internal property: namespace context */
+ protected static final String NAMESPACE_CONTEXT_PROPERTY =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.NAMESPACE_CONTEXT_PROPERTY;
+
// recognized features and properties
/** Recognized features. */
@@ -162,7 +166,7 @@
// namespaces
/** Namespace support. */
- protected NamespaceSupport fNamespaceSupport = new NamespaceSupport();
+ protected NamespaceSupport fNamespaceSupport = null;
// settings
@@ -264,6 +268,7 @@
// Xerces properties
fSymbolTable = (SymbolTable)componentManager.getProperty(SYMBOL_TABLE);
fErrorReporter = (XMLErrorReporter)componentManager.getProperty(ERROR_REPORTER);
+ fNamespaceSupport = (NamespaceSupport)componentManager.getProperty(NAMESPACE_CONTEXT_PROPERTY);
// initialize vars
fNamespaceSupport.reset();
1.33 +13 -10 xml-xerces/java/src/org/apache/xerces/impl/dtd/XMLDTDValidator.java
Index: XMLDTDValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dtd/XMLDTDValidator.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- XMLDTDValidator.java 12 Sep 2002 21:56:57 -0000 1.32
+++ XMLDTDValidator.java 16 Sep 2002 21:36:40 -0000 1.33
@@ -1046,13 +1046,9 @@
return fValidation && (!fDynamicValidation || fSeenDoctypeDecl)
&& (fDTDValidation || fSeenDoctypeDecl);
}
-
- //
- // Private methods
- //
-
+
/** Add default attributes and validate. */
- private void addDTDDefaultAttrsAndValidate(int elementIndex,
+ protected void addDTDDefaultAttrsAndValidate(int elementIndex,
XMLAttributes attributes)
throws XNIException {
@@ -1264,7 +1260,7 @@
} // addDTDDefaultAttrsAndValidate(int,XMLAttrList)
/** Checks entities in attribute values for standalone VC. */
- private String getExternalEntityRefInAttrValue(String nonNormalizedValue) {
+ protected String getExternalEntityRefInAttrValue(String nonNormalizedValue) {
int valLength = nonNormalizedValue.length();
int ampIndex = nonNormalizedValue.indexOf('&');
while (ampIndex != -1) {
@@ -1290,7 +1286,7 @@
/**
* Validate attributes in DTD fashion.
*/
- private void validateDTDattribute(QName element, String attValue,
+ protected void validateDTDattribute(QName element, String attValue,
XMLAttributeDecl attributeDecl)
throws XNIException {
@@ -1416,8 +1412,9 @@
} // validateDTDattribute(QName,String,XMLAttributeDecl)
+
/** Returns true if invalid standalone attribute definition. */
- boolean invalidStandaloneAttDef(QName element, QName attribute) {
+ protected boolean invalidStandaloneAttDef(QName element, QName attribute) {
// REVISIT: This obviously needs to be fixed! -Ac
boolean state = true;
/*
@@ -1432,6 +1429,12 @@
*/
return state;
}
+
+
+ //
+ // Private methods
+ //
+
/**
* Normalize the attribute value of a non CDATA attributes collapsing
1.2 +9 -3 xml-xerces/java/src/org/apache/xerces/impl/dtd/XMLNSDTDValidator.java
Index: XMLNSDTDValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/dtd/XMLNSDTDValidator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XMLNSDTDValidator.java 12 Sep 2002 21:56:57 -0000 1.1
+++ XMLNSDTDValidator.java 16 Sep 2002 21:36:40 -0000 1.2
@@ -57,6 +57,7 @@
package org.apache.xerces.impl.dtd;
+import org.apache.xerces.impl.Constants;
import org.apache.xerces.impl.XMLErrorReporter;
import org.apache.xerces.impl.msg.XMLMessageFormatter;
@@ -106,15 +107,20 @@
/** Namespace support. */
- protected NamespaceSupport fNamespaceSupport = new NamespaceSupport();
+ protected NamespaceSupport fNamespaceSupport = null;
+ /** Internal property: namespace context */
+ protected static final String NAMESPACE_CONTEXT_PROPERTY =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.NAMESPACE_CONTEXT_PROPERTY;
/** Attribute QName. */
private QName fAttributeQName = new QName();
public void reset(XMLComponentManager componentManager){
super.reset(componentManager);
- fNamespaceSupport.reset();
+
+ // internal xerces property: namespace context
+ fNamespaceSupport = (NamespaceSupport)componentManager.getProperty(NAMESPACE_CONTEXT_PROPERTY);
}
1.97 +17 -45 xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
Index: XMLSchemaValidator.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -r1.96 -r1.97
--- XMLSchemaValidator.java 16 Sep 2002 18:26:09 -0000 1.96
+++ XMLSchemaValidator.java 16 Sep 2002 21:36:40 -0000 1.97
@@ -213,6 +213,10 @@
protected static final String JAXP_SCHEMA_SOURCE =
Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_SOURCE;
+ /** Internal property: namespace context */
+ protected static final String NAMESPACE_CONTEXT_PROPERTY =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.NAMESPACE_CONTEXT_PROPERTY;
+
// recognized features and properties
/** Recognized features. */
@@ -231,7 +235,8 @@
VALIDATION_MANAGER,
SCHEMA_LOCATION,
SCHEMA_NONS_LOCATION,
- JAXP_SCHEMA_SOURCE
+ JAXP_SCHEMA_SOURCE,
+ NAMESPACE_CONTEXT_PROPERTY
};
// this is the number of valuestores of each kind
@@ -556,7 +561,7 @@
if (DEBUG) {
System.out.println("startPrefixMapping("+prefix+","+uri+")");
}
- handleStartPrefix(prefix, uri);
+
// call handlers
if (fDocumentHandler != null) {
fDocumentHandler.startPrefixMapping(prefix, uri, augs);
@@ -1006,11 +1011,8 @@
final XMLSchemaLoader fSchemaLoader;
/** Namespace support. */
- final NamespaceSupport fNamespaceSupport = new NamespaceSupport();
- /** this flag is used to indicate whether the next prefix binding
- * should start a new context (.pushContext)
- */
- boolean fPushForNextBinding;
+ protected NamespaceSupport fNamespaceSupport = null;
+
/** the DV usd to convert xsi:type to a QName */
// REVISIT: in new simple type design, make things in DVs static,
// so that we can QNameDV.getCompiledForm()
@@ -1139,11 +1141,8 @@
// initialize the schema loader
fSchemaLoader = new XMLSchemaLoader(fXSIErrorReporter.fErrorReporter, fGrammarBucket, fSubGroupHandler, fCMBuilder);
- fValidationState.setNamespaceSupport(fNamespaceSupport);
fState4XsiType.setExtraChecking(false);
- fState4XsiType.setNamespaceSupport(fNamespaceSupport);
fState4ApplyDefault.setFacetChecking(false);
- fState4ApplyDefault.setNamespaceSupport(fNamespaceSupport);
} // <init>()
@@ -1174,6 +1173,13 @@
fSymbolTable = symbolTable;
}
+
+ // internal xerces property: namespace-context
+ fNamespaceSupport = (NamespaceSupport)componentManager.getProperty(NAMESPACE_CONTEXT_PROPERTY);
+ fValidationState.setNamespaceSupport(fNamespaceSupport);
+ fState4XsiType.setNamespaceSupport(fNamespaceSupport);
+ fState4ApplyDefault.setNamespaceSupport(fNamespaceSupport);
+
try {
fValidation = componentManager.getFeature(VALIDATION);
}
@@ -1223,9 +1229,6 @@
fEntityResolver = (XMLEntityResolver)componentManager.getProperty(ENTITY_MANAGER);
fSchemaLoader.setEntityResolver(fEntityResolver);
- // initialize namespace support
- fNamespaceSupport.reset();
- fPushForNextBinding = true;
fValidationManager = (ValidationManager)componentManager.getProperty(VALIDATION_MANAGER);
fValidationManager.addValidationState(fValidationState);
fValidationState.setSymbolTable(fSymbolTable);
@@ -1644,18 +1647,6 @@
}
fCurrentPSVI.reset();
- // we receive prefix binding events before this one,
- // so at this point, the prefix bindings for this element is done,
- // and we need to push context when we receive another prefix binding.
-
- // but if fPushForNextBinding is still true, that means there has
- // been no prefix binding for this element. we still need to push
- // context, because the context is always popped in end element.
- if (fPushForNextBinding)
- fNamespaceSupport.pushContext();
- else
- fPushForNextBinding = true;
-
// root element
if (fElementDepth == -1) {
// at this point we assume that no XML schemas found in the instance document
@@ -1994,10 +1985,6 @@
fElementDepth--;
}
- // need to pop context so that the bindings for this element is
- // discarded.
- fNamespaceSupport.popContext();
-
// pop error reporter context: get all errors for the current
// element, and remove them from the error list
// String[] errors = fXSIErrorReporter.popContext();
@@ -2098,10 +2085,6 @@
fSawChildren = fSawChildrenStack[fElementDepth];
}
- // need to pop context so that the bindings for this element is
- // discarded.
- fNamespaceSupport.popContext();
-
fCurrentPSVI.fDeclaration = this.fCurrentElemDecl;
fCurrentPSVI.fTypeDecl = this.fCurrentType;
fCurrentPSVI.fNotation = this.fNotation;
@@ -2134,17 +2117,6 @@
return augs;
} // handleEndElement(QName,boolean)*/
-
- void handleStartPrefix(String prefix, String uri) {
- // push namespace context if necessary
- if (fPushForNextBinding) {
- fNamespaceSupport.pushContext();
- fPushForNextBinding = false;
- }
-
- // add prefix declaration to the namespace support
- fNamespaceSupport.declarePrefix(prefix, uri.length() != 0 ? uri : null);
- }
void storeLocations(String sLocation, String nsLocation){
if (sLocation != null) {
1.7 +3 -3 xml-xerces/java/src/org/apache/xerces/impl/xs/dom/DOMParser.java
Index: DOMParser.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/dom/DOMParser.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DOMParser.java 12 Sep 2002 21:56:57 -0000 1.6
+++ DOMParser.java 16 Sep 2002 21:36:41 -0000 1.7
@@ -57,7 +57,7 @@
package org.apache.xerces.impl.xs.dom;
-import org.apache.xerces.parsers.IntegratedParserConfiguration;
+import org.apache.xerces.parsers.NonValidatingConfiguration;
import org.apache.xerces.impl.Constants;
import org.apache.xerces.impl.XMLErrorReporter;
import org.apache.xerces.impl.xs.SchemaSymbols;
@@ -117,7 +117,7 @@
// REVISIT: should we use a new configuration with scannerNS->dom API with
// no dtd scanners/valitors..?
//
- super(new IntegratedParserConfiguration());
+ super(new NonValidatingConfiguration());
try {
// use our own document implementation
setProperty(DOCUMENT_CLASS, "org.apache.xerces.impl.xs.dom.DocumentImpl");
1.11 +17 -2 xml-xerces/java/src/org/apache/xerces/parsers/BasicParserConfiguration.java
Index: BasicParserConfiguration.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/BasicParserConfiguration.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- BasicParserConfiguration.java 20 May 2002 20:29:30 -0000 1.10
+++ BasicParserConfiguration.java 16 Sep 2002 21:36:41 -0000 1.11
@@ -68,6 +68,7 @@
import org.apache.xerces.impl.msg.XMLMessageFormatter;
import org.apache.xerces.util.ParserConfigurationSettings;
import org.apache.xerces.util.SymbolTable;
+import org.apache.xerces.util.NamespaceSupport;
import org.apache.xerces.xni.XMLDocumentHandler;
import org.apache.xerces.xni.XMLDTDHandler;
import org.apache.xerces.xni.XMLDTDContentModelHandler;
@@ -177,6 +178,10 @@
protected static final String ENTITY_RESOLVER =
Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY;
+ /** Property identifier: namespace context */
+ protected static final String NAMESPACE_CONTEXT_PROPERTY =
+ Constants.XERCES_PROPERTY_PREFIX + Constants.NAMESPACE_CONTEXT_PROPERTY;
+
//
// Data
//
@@ -186,6 +191,10 @@
/** Symbol table. */
protected SymbolTable fSymbolTable;
+
+ /** Read/write namespace context */
+ protected NamespaceSupport fNamespaceContext;
+
// data
/** Locale. */
@@ -269,6 +278,7 @@
SYMBOL_TABLE,
ERROR_HANDLER,
ENTITY_RESOLVER,
+ NAMESPACE_CONTEXT_PROPERTY
};
addRecognizedProperties(recognizedProperties);
@@ -278,6 +288,8 @@
fSymbolTable = symbolTable;
setProperty(SYMBOL_TABLE, fSymbolTable);
+ fNamespaceContext = new NamespaceSupport();
+ setProperty(NAMESPACE_CONTEXT_PROPERTY, fNamespaceContext);
} // <init>(SymbolTable)
/**
@@ -512,9 +524,12 @@
//
/**
- * reset all components before parsing
+ * reset all components before parsing and namespace context
*/
protected void reset() throws XNIException {
+
+ // reset namespace context before the next parse
+ fNamespaceContext.reset();
// reset every component
int count = fComponents.size();
1.63 +2 -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.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- DOMParser.java 26 Apr 2002 10:33:30 -0000 1.62
+++ DOMParser.java 16 Sep 2002 21:36:41 -0000 1.63
@@ -152,7 +152,7 @@
public DOMParser(SymbolTable symbolTable, XMLGrammarPool grammarPool) {
super((XMLParserConfiguration)ObjectFactory.createObject(
"org.apache.xerces.xni.parser.XMLParserConfiguration",
- "org.apache.xerces.parsers.StandardParserConfiguration"
+ "org.apache.xerces.parsers.IntegratedParserConfiguration"
));
// set properties
1.33 +2 -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.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- SAXParser.java 26 Apr 2002 10:33:30 -0000 1.32
+++ SAXParser.java 16 Sep 2002 21:36:41 -0000 1.33
@@ -139,7 +139,7 @@
public SAXParser(SymbolTable symbolTable, XMLGrammarPool grammarPool) {
super((XMLParserConfiguration)ObjectFactory.createObject(
"org.apache.xerces.xni.parser.XMLParserConfiguration",
- "org.apache.xerces.parsers.StandardParserConfiguration"
+ "org.apache.xerces.parsers.IntegratedParserConfiguration"
));
// set features
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org