neilg 2003/06/05 14:49:04
Modified: java/src/org/apache/xerces/impl XMLScanner.java
XMLDTDScannerImpl.java
XMLDocumentFragmentScannerImpl.java
Log:
fix non-conformance to namespaces (1.0 and 1.1) with respect to ENTITY/NOTATION/PI
names
Revision Changes Path
1.33 +33 -5 xml-xerces/java/src/org/apache/xerces/impl/XMLScanner.java
Index: XMLScanner.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLScanner.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- XMLScanner.java 29 May 2003 13:25:41 -0000 1.32
+++ XMLScanner.java 5 Jun 2003 21:49:03 -0000 1.33
@@ -82,7 +82,8 @@
* This component requires the following features and properties from the
* component manager that uses it:
* <ul>
- * <li>http://xml.org/sax/features/validation</li>
+ * <li>http://xml.org/sax/features/validation</li>
+ * <li>http://xml.org/sax/features/namespaces</li>
* <li>http://apache.org/xml/features/scanner/notify-char-refs</li>
* <li>http://apache.org/xml/properties/internal/symbol-table</li>
* <li>http://apache.org/xml/properties/internal/error-reporter</li>
@@ -108,6 +109,10 @@
protected static final String VALIDATION =
Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;
+ /** Feature identifier: namespaces. */
+ protected static final String NAMESPACES =
+ Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
+
/** Feature identifier: notify character references. */
protected static final String NOTIFY_CHAR_REFS =
Constants.XERCES_FEATURE_PREFIX + Constants.NOTIFY_CHAR_REFS_FEATURE;
@@ -143,6 +148,9 @@
*/
protected boolean fValidation = false;
+ /** Namespaces. */
+ protected boolean fNamespaces;
+
/** Character references notification. */
protected boolean fNotifyCharRefs = false;
@@ -252,6 +260,12 @@
fValidation = false;
}
try {
+ fNamespaces = componentManager.getFeature(NAMESPACES);
+ }
+ catch (XMLConfigurationException e) {
+ fNamespaces = true;
+ }
+ try {
fNotifyCharRefs = componentManager.getFeature(NOTIFY_CHAR_REFS);
}
catch (XMLConfigurationException e) {
@@ -598,7 +612,12 @@
// target
fReportEntity = false;
- String target = fEntityScanner.scanName();
+ String target = null;
+ if(fNamespaces) {
+ target = fEntityScanner.scanNCName();
+ } else {
+ target = fEntityScanner.scanName();
+ }
if (target == null) {
reportFatalError("PITargetRequired", null);
}
@@ -641,8 +660,17 @@
return;
}
else {
- // if there is data there should be some space
- reportFatalError("SpaceRequiredInPI", null);
+ if(fNamespaces && fEntityScanner.peekChar() == ':') {
+ fEntityScanner.scanChar();
+ XMLStringBuffer colonName = new XMLStringBuffer(target);
+ colonName.append(":");
+ colonName.append(fEntityScanner.scanName());
+ reportFatalError("ColonNotLegalWithNS", new Object[]
{colonName.toString()});
+ fEntityScanner.skipSpaces();
+ } else {
+ // if there is data there should be some space
+ reportFatalError("SpaceRequiredInPI", null);
+ }
}
}
1.42 +37 -6
xml-xerces/java/src/org/apache/xerces/impl/XMLDTDScannerImpl.java
Index: XMLDTDScannerImpl.java
===================================================================
RCS file:
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLDTDScannerImpl.java,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- XMLDTDScannerImpl.java 14 May 2003 19:24:17 -0000 1.41
+++ XMLDTDScannerImpl.java 5 Jun 2003 21:49:03 -0000 1.42
@@ -1473,13 +1473,29 @@
}
// name
- String name = fEntityScanner.scanName();
+ String name = null;
+ if(fNamespaces) {
+ name = fEntityScanner.scanNCName();
+ } else {
+ name = fEntityScanner.scanName();
+ }
if (name == null) {
reportFatalError("MSG_ENTITY_NAME_REQUIRED_IN_ENTITYDECL", null);
}
-
// spaces
if (!skipSeparator(true, !scanningInternalSubset())) {
+ if(fNamespaces && fEntityScanner.peekChar() == ':') {
+ fEntityScanner.scanChar();
+ XMLStringBuffer colonName = new XMLStringBuffer(name);
+ colonName.append(":");
+ colonName.append(fEntityScanner.scanName());
+ reportFatalError("ColonNotLegalWithNS", new Object[]
{colonName.toString()});
+ }
+ if (!skipSeparator(true, !scanningInternalSubset())) {
+
reportFatalError("MSG_SPACE_REQUIRED_AFTER_ENTITY_NAME_IN_ENTITYDECL",
+ new Object[]{name});
+ }
+ } else {
reportFatalError("MSG_SPACE_REQUIRED_AFTER_ENTITY_NAME_IN_ENTITYDECL",
new Object[]{name});
}
@@ -1707,7 +1723,12 @@
}
// notation name
- String name = fEntityScanner.scanName();
+ String name = null;
+ if(fNamespaces) {
+ name = fEntityScanner.scanNCName();
+ } else {
+ name = fEntityScanner.scanName();
+ }
if (name == null) {
reportFatalError("MSG_NOTATION_NAME_REQUIRED_IN_NOTATIONDECL",
null);
@@ -1715,8 +1736,18 @@
// spaces
if (!skipSeparator(true, !scanningInternalSubset())) {
-
reportFatalError("MSG_SPACE_REQUIRED_AFTER_NOTATION_NAME_IN_NOTATIONDECL",
- new Object[]{name});
+ // check for invalid ":"
+ if(fNamespaces && fEntityScanner.peekChar() == ':') {
+ fEntityScanner.scanChar();
+ XMLStringBuffer colonName = new XMLStringBuffer(name);
+ colonName.append(":");
+ colonName.append(fEntityScanner.scanName());
+ reportFatalError("ColonNotLegalWithNS", new Object[]
{colonName.toString()});
+ skipSeparator(true, !scanningInternalSubset());
+ } else {
+
reportFatalError("MSG_SPACE_REQUIRED_AFTER_NOTATION_NAME_IN_NOTATIONDECL",
+ new Object[]{name});
+ }
}
// external id
1.34 +1 -11
xml-xerces/java/src/org/apache/xerces/impl/XMLDocumentFragmentScannerImpl.java
Index: XMLDocumentFragmentScannerImpl.java
===================================================================
RCS file:
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/XMLDocumentFragmentScannerImpl.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- XMLDocumentFragmentScannerImpl.java 29 May 2003 13:25:41 -0000 1.33
+++ XMLDocumentFragmentScannerImpl.java 5 Jun 2003 21:49:03 -0000 1.34
@@ -85,7 +85,6 @@
* This component requires the following features and properties from the
* component manager that uses it:
* <ul>
- * <li>http://xml.org/sax/features/namespaces</li>
* <li>http://xml.org/sax/features/validation</li>
* <li>http://apache.org/xml/features/scanner/notify-char-refs</li>
* <li>http://apache.org/xml/features/scanner/notify-builtin-refs</li>
@@ -241,9 +240,6 @@
// features
- /** Namespaces. */
- protected boolean fNamespaces;
-
/** Notify built-in references. */
protected boolean fNotifyBuiltInRefs = false;
@@ -374,12 +370,6 @@
//fDocumentSystemId = null;
// sax features
- try {
- fNamespaces = componentManager.getFeature(NAMESPACES);
- }
- catch (XMLConfigurationException e) {
- fNamespaces = true;
- }
fAttributes.setNamespaces(fNamespaces);
// xerces features
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]