mrglavas 2005/09/07 20:55:37
Modified: java/src/org/apache/xerces/xinclude XIncludeHandler.java
Log:
Fixing a bug. If the start document event has been seen on the child pipeline
it
means the resource was successfully opened and we started reporting document
events. If an IOException is thrown after the start document event we had a
failure midstream and cannot recover. We were treating this condition as a
resource
error and allowing a malformed stream of events to be reported by the parser.
Revision Changes Path
1.57 +22 -9
xml-xerces/java/src/org/apache/xerces/xinclude/XIncludeHandler.java
Index: XIncludeHandler.java
===================================================================
RCS file:
/home/cvs/xml-xerces/java/src/org/apache/xerces/xinclude/XIncludeHandler.java,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- XIncludeHandler.java 25 Jul 2005 18:04:26 -0000 1.56
+++ XIncludeHandler.java 8 Sep 2005 03:55:37 -0000 1.57
@@ -340,6 +340,9 @@
// track whether a DTD is being parsed
private boolean fInDTD;
+ // tracks whether start document has been called on the child pipeline
+ private boolean fChildHasSeenStartDocument;
+
// track whether the root element of the result infoset has been
processed
private boolean fSeenRootElement;
@@ -745,11 +748,13 @@
// otherwise, the locator from the root document would always be used
fErrorReporter.setDocumentLocator(locator);
- if (!isRootDocument()
- && fParentXIncludeHandler.searchForRecursiveIncludes(locator)) {
- reportFatalError(
- "RecursiveInclude",
- new Object[] { locator.getExpandedSystemId()});
+ if (!isRootDocument()) {
+ fParentXIncludeHandler.fChildHasSeenStartDocument = true;
+ if (fParentXIncludeHandler.searchForRecursiveIncludes(locator)) {
+ reportFatalError(
+ "RecursiveInclude",
+ new Object[] { locator.getExpandedSystemId()});
+ }
}
if (!(namespaceContext instanceof XIncludeNamespaceSupport)) {
@@ -1660,6 +1665,7 @@
fNeedCopyFeatures = false;
try {
+ fChildHasSeenStartDocument = false;
fNamespaceContext.pushScope();
fChildConfig.parse(includedSource);
@@ -1692,9 +1698,16 @@
if (fErrorReporter != null) {
fErrorReporter.setDocumentLocator(fDocLocation);
}
- // An IOException indicates that we had trouble reading the
file, not
- // that it was an invalid XML file. So we send a resource
error, not a
- // fatal error.
+ // If the start document event has been seen on the child
pipeline it
+ // means the resource was successfully opened and we started
reporting
+ // document events. If an IOException is thrown after the
start document
+ // event we had a failure midstream and cannot recover.
+ if (fChildHasSeenStartDocument) {
+ throw new XNIException(e);
+ }
+ // In other circumstances an IOException indicates that we
had trouble
+ // accessing or opening the file, not that it was an invalid
XML file. So we
+ // send a resource error, not a fatal error.
reportResourceError(
"XMLResourceError",
new Object[] { href, e.getMessage()});
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]