mrglavas 2005/09/13 13:45:05
Modified: java/src/org/apache/xerces/xinclude XIncludeHandler.java
XIncludeTextReader.java
Log:
Expanding on the previous fix. If parse="text" and an IOException has
been thrown after we start reporting content we cannot recover from
this error.
Revision Changes Path
1.58 +14 -6
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.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- XIncludeHandler.java 8 Sep 2005 03:55:37 -0000 1.57
+++ XIncludeHandler.java 13 Sep 2005 20:45:04 -0000 1.58
@@ -340,8 +340,8 @@
// track whether a DTD is being parsed
private boolean fInDTD;
- // tracks whether start document has been called on the child pipeline
- private boolean fChildHasSeenStartDocument;
+ // tracks whether content has been reported on the child pipeline
+ boolean fHasIncludeReportedContent;
// track whether the root element of the result infoset has been
processed
private boolean fSeenRootElement;
@@ -749,7 +749,7 @@
fErrorReporter.setDocumentLocator(locator);
if (!isRootDocument()) {
- fParentXIncludeHandler.fChildHasSeenStartDocument = true;
+ fParentXIncludeHandler.fHasIncludeReportedContent = true;
if (fParentXIncludeHandler.searchForRecursiveIncludes(locator)) {
reportFatalError(
"RecursiveInclude",
@@ -1665,7 +1665,7 @@
fNeedCopyFeatures = false;
try {
- fChildHasSeenStartDocument = false;
+ fHasIncludeReportedContent = false;
fNamespaceContext.pushScope();
fChildConfig.parse(includedSource);
@@ -1702,7 +1702,7 @@
// 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) {
+ if (fHasIncludeReportedContent) {
throw new XNIException(e);
}
// In other circumstances an IOException indicates that we
had trouble
@@ -1724,6 +1724,8 @@
XIncludeTextReader textReader = null;
try {
+ fHasIncludeReportedContent = false;
+
// Setup the appropriate text reader.
if (!fIsXML11) {
if (fXInclude10TextReader == null) {
@@ -1756,6 +1758,12 @@
"CharConversionFailure", null,
XMLErrorReporter.SEVERITY_FATAL_ERROR);
}
catch (IOException e) {
+ // If a characters event has already been sent down the
pipeline it
+ // means the resource was successfully opened and that this
IOException
+ // is from a failure midstream from which we cannot recover.
+ if (fHasIncludeReportedContent) {
+ throw new XNIException(e);
+ }
reportResourceError(
"TextResourceError",
new Object[] { href, e.getMessage()});
1.16 +2 -2
xml-xerces/java/src/org/apache/xerces/xinclude/XIncludeTextReader.java
Index: XIncludeTextReader.java
===================================================================
RCS file:
/home/cvs/xml-xerces/java/src/org/apache/xerces/xinclude/XIncludeTextReader.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- XIncludeTextReader.java 8 May 2005 18:21:08 -0000 1.15
+++ XIncludeTextReader.java 13 Sep 2005 20:45:04 -0000 1.16
@@ -408,10 +408,10 @@
* @throws IOException
*/
public void parse() throws IOException {
-
fReader = getReader(fSource);
fSource = null;
int readSize = fReader.read(fTempString.ch, 0, fTempString.ch.length
- 1);
+ fHandler.fHasIncludeReportedContent = true;
while (readSize != -1) {
for (int i = 0; i < readSize; ++i) {
char ch = fTempString.ch[i];
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]