You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by an...@apache.org on 2001/06/26 05:31:44 UTC
cvs commit: xml-xerces/java/src/org/apache/xerces/parsers AbstractSAXParser.java
andyc 01/06/25 20:31:44
Modified: java/src/org/apache/xerces/impl Tag: xerces_j_2
XMLNamespaceBinder.java
java/src/org/apache/xerces/parsers Tag: xerces_j_2
AbstractSAXParser.java
Log:
Fixed namespace bugs:
1) When namespaces was turned off, localName was being passed
as the same value of qName. In other words, "x:foo" element
would be passed as {"","x:foo","x:foo",""}.
2) Unqualified attributes were picking up URI binding from
element.
Revision Changes Path
No revision
No revision
1.1.2.10 +6 -10 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.9
retrieving revision 1.1.2.10
diff -u -r1.1.2.9 -r1.1.2.10
--- XMLNamespaceBinder.java 2001/05/09 07:20:28 1.1.2.9
+++ XMLNamespaceBinder.java 2001/06/26 03:31:42 1.1.2.10
@@ -93,7 +93,7 @@
*
* @author Andy Clark, IBM
*
- * @version $Id: XMLNamespaceBinder.java,v 1.1.2.9 2001/05/09 07:20:28 andyc Exp $
+ * @version $Id: XMLNamespaceBinder.java,v 1.1.2.10 2001/06/26 03:31:42 andyc Exp $
*/
public class XMLNamespaceBinder
implements XMLComponent, XMLDocumentHandler {
@@ -530,28 +530,24 @@
// bind the attributes
for (int i = 0; i < length; i++) {
attributes.getName(i, fAttributeQName);
- String arawname = fAttributeQName.rawname;
String aprefix = fAttributeQName.prefix != null
? fAttributeQName.prefix : fEmptySymbol;
+ String arawname = fAttributeQName.rawname;
if (aprefix == fXmlSymbol) {
fAttributeQName.uri = fNamespaceSupport.getURI(fXmlSymbol);
attributes.setName(i, fAttributeQName);
}
else if (arawname != fXmlnsSymbol && !arawname.startsWith("xmlns:")) {
- if (fAttributeQName.prefix != null) {
- fAttributeQName.uri = fNamespaceSupport.getURI(fAttributeQName.prefix);
+ if (aprefix != fEmptySymbol) {
+ fAttributeQName.uri = fNamespaceSupport.getURI(aprefix);
if (fAttributeQName.uri == null) {
fErrorReporter.reportError(XMLMessageFormatter.XMLNS_DOMAIN,
"AttributePrefixUnbound",
- new Object[]{fAttributeQName.prefix, fAttributeQName.rawname},
+ new Object[]{aprefix, arawname},
XMLErrorReporter.SEVERITY_FATAL_ERROR);
}
+ attributes.setName(i, fAttributeQName);
}
- else {
- // attributes with no prefix get element's uri
- fAttributeQName.uri = element.uri;
- }
- attributes.setName(i, fAttributeQName);
}
}
No revision
No revision
1.1.2.13 +36 -13 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.12
retrieving revision 1.1.2.13
diff -u -r1.1.2.12 -r1.1.2.13
--- AbstractSAXParser.java 2001/05/09 07:20:44 1.1.2.12
+++ AbstractSAXParser.java 2001/06/26 03:31:43 1.1.2.13
@@ -91,7 +91,7 @@
* @author Arnaud Le Hors, IBM
* @author Andy Clark, IBM
*
- * @version $Id: AbstractSAXParser.java,v 1.1.2.12 2001/05/09 07:20:44 andyc Exp $
+ * @version $Id: AbstractSAXParser.java,v 1.1.2.13 2001/06/26 03:31:43 andyc Exp $
*/
public abstract class AbstractSAXParser
extends AbstractXMLDocumentParser
@@ -102,6 +102,16 @@
// Constants
//
+ // features
+
+ /** Feature identifier: namespaces. */
+ protected static final String NAMESPACES =
+ Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
+
+ /** Feature identifier: namespace prefixes. */
+ protected static final String NAMESPACE_PREFIXES =
+ Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACE_PREFIXES_FEATURE;
+
// NOTE: The locator and symbol table properties are for internal
// use. -Ac
@@ -118,8 +128,12 @@
//
// features
+
+ /** Namespaces. */
+ protected boolean fNamespaces;
- boolean fNamespacePrefixes = false;
+ /** Namespace prefixes. */
+ protected boolean fNamespacePrefixes = false;
// parser handlers
@@ -164,19 +178,16 @@
super(config);
final String[] recognizedFeatures = {
- Constants.SAX_FEATURE_PREFIX +
- Constants.NAMESPACE_PREFIXES_FEATURE,
- Constants.SAX_FEATURE_PREFIX +
- Constants.STRING_INTERNING_FEATURE
+ NAMESPACES,
+ NAMESPACE_PREFIXES,
+ Constants.SAX_FEATURE_PREFIX + Constants.STRING_INTERNING_FEATURE,
};
config.addRecognizedFeatures(recognizedFeatures);
final String[] recognizedProperties = {
- Constants.SAX_PROPERTY_PREFIX +
- Constants.LEXICAL_HANDLER_PROPERTY,
- Constants.SAX_PROPERTY_PREFIX +
- Constants.DECLARATION_HANDLER_PROPERTY,
- Constants.SAX_PROPERTY_PREFIX + Constants.DOM_NODE_PROPERTY
+ Constants.SAX_PROPERTY_PREFIX + Constants.LEXICAL_HANDLER_PROPERTY,
+ Constants.SAX_PROPERTY_PREFIX + Constants.DECLARATION_HANDLER_PROPERTY,
+ Constants.SAX_PROPERTY_PREFIX + Constants.DOM_NODE_PROPERTY,
};
config.addRecognizedProperties(recognizedProperties);
@@ -323,7 +334,8 @@
}
String uri = element.uri != null ? element.uri : fEmptySymbol;
- fContentHandler.startElement(uri, element.localpart,
+ String localpart = fNamespaces ? element.localpart : fEmptySymbol;
+ fContentHandler.startElement(uri, localpart,
element.rawname, attributes);
}
}
@@ -415,7 +427,8 @@
// SAX2
if (fContentHandler != null) {
String uri = element.uri != null ? element.uri : fEmptySymbol;
- fContentHandler.endElement(uri, element.localpart,
+ String localpart = fNamespaces ? element.localpart : fEmptySymbol;
+ fContentHandler.endElement(uri, localpart,
element.rawname);
}
}
@@ -981,6 +994,12 @@
if (featureId.startsWith(Constants.SAX_FEATURE_PREFIX)) {
String feature = featureId.substring(Constants.SAX_FEATURE_PREFIX.length());
+ // http://xml.org/sax/features/namespaces
+ if (feature.equals(Constants.NAMESPACES_FEATURE)) {
+ fConfiguration.setFeature(featureId, state);
+ fNamespaces = state;
+ return;
+ }
// http://xml.org/sax/features/namespace-prefixes
// controls the reporting of raw prefixed names and Namespace
// declarations (xmlns* attributes): when this feature is false
@@ -1386,6 +1405,10 @@
// reset state
fInDTD = false;
+
+ // features
+ fNamespaces = fConfiguration.getFeature(NAMESPACES);
+ fNamespacePrefixes = fConfiguration.getFeature(NAMESPACE_PREFIXES);
// save needed symbols
SymbolTable symbolTable = (SymbolTable)fConfiguration.getProperty(SYMBOL_TABLE);
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org