aboutsummaryrefslogtreecommitdiff
path: root/common/src/at/gv/egovernment/moa
diff options
context:
space:
mode:
authorrudolf <rudolf@d688527b-c9ab-4aba-bd8d-4036d912da1d>2004-04-26 12:47:06 +0000
committerrudolf <rudolf@d688527b-c9ab-4aba-bd8d-4036d912da1d>2004-04-26 12:47:06 +0000
commit6f2b4760a460ad3eeedbd5b475d7ecbfdc77179c (patch)
tree92917cebb1cb2445a60656937f256be840a2d691 /common/src/at/gv/egovernment/moa
parent86b51fd16f65996db588ee4a20bfda177b2dcd2e (diff)
downloadmoa-id-spss-6f2b4760a460ad3eeedbd5b475d7ecbfdc77179c.tar.gz
moa-id-spss-6f2b4760a460ad3eeedbd5b475d7ecbfdc77179c.tar.bz2
moa-id-spss-6f2b4760a460ad3eeedbd5b475d7ecbfdc77179c.zip
Debug logging des Dokuments im Falle einer SAXException wurde hinzugefĆ¼gt (RSCH)
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@106 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'common/src/at/gv/egovernment/moa')
-rw-r--r--common/src/at/gv/egovernment/moa/util/DOMUtils.java82
1 files changed, 52 insertions, 30 deletions
diff --git a/common/src/at/gv/egovernment/moa/util/DOMUtils.java b/common/src/at/gv/egovernment/moa/util/DOMUtils.java
index 8e6394445..f44804927 100644
--- a/common/src/at/gv/egovernment/moa/util/DOMUtils.java
+++ b/common/src/at/gv/egovernment/moa/util/DOMUtils.java
@@ -41,6 +41,8 @@ import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+import at.gv.egovernment.moa.logging.Logger;
+
/**
* Various utility functions for handling XML DOM trees.
*
@@ -154,10 +156,22 @@ public class DOMUtils {
String externalNoNamespaceSchemaLocation,
EntityResolver entityResolver,
ErrorHandler errorHandler)
- throws SAXException, IOException, ParserConfigurationException {
+ throws SAXException, IOException, ParserConfigurationException {
DOMParser parser;
+
+
+ //if Debug is enabled make a copy of inputStream to enable debug output in case of SAXException
+ byte buffer [] = null;
+ ByteArrayInputStream baStream = null;
+ if(true == Logger.isDebugEnabled()) {
+ int len = inputStream.available();
+ buffer = new byte[len];
+ inputStream.read(buffer);
+ baStream = new ByteArrayInputStream(buffer);
+ }
+
// create the DOM parser
if (symbolTable != null) {
parser = new DOMParser(symbolTable, grammarPool);
@@ -166,36 +180,44 @@ public class DOMUtils {
}
// set parser features and properties
- parser.setFeature(NAMESPACES_FEATURE, true);
- parser.setFeature(VALIDATION_FEATURE, validating);
- parser.setFeature(SCHEMA_VALIDATION_FEATURE, validating);
- parser.setFeature(NORMALIZED_VALUE_FEATURE, false);
- parser.setFeature(INCLUDE_IGNORABLE_WHITESPACE_FEATURE, true);
- parser.setFeature(CREATE_ENTITY_REF_NODES_FEATURE, false);
-
- if (validating) {
- if (externalSchemaLocations != null) {
- parser.setProperty(
- EXTERNAL_SCHEMA_LOCATION_PROPERTY,
- externalSchemaLocations);
- }
- if (externalNoNamespaceSchemaLocation != null) {
- parser.setProperty(
- EXTERNAL_NO_NAMESPACE_SCHEMA_LOCATION_PROPERTY,
- externalNoNamespaceSchemaLocation);
- }
- }
-
- // set entity resolver and error handler
- if (entityResolver != null) {
- parser.setEntityResolver(entityResolver);
+ try {
+ parser.setFeature(NAMESPACES_FEATURE, true);
+ parser.setFeature(VALIDATION_FEATURE, validating);
+ parser.setFeature(SCHEMA_VALIDATION_FEATURE, validating);
+ parser.setFeature(NORMALIZED_VALUE_FEATURE, false);
+ parser.setFeature(INCLUDE_IGNORABLE_WHITESPACE_FEATURE, true);
+ parser.setFeature(CREATE_ENTITY_REF_NODES_FEATURE, false);
+
+ if (validating) {
+ if (externalSchemaLocations != null) {
+ parser.setProperty(
+ EXTERNAL_SCHEMA_LOCATION_PROPERTY,
+ externalSchemaLocations);
+ }
+ if (externalNoNamespaceSchemaLocation != null) {
+ parser.setProperty(
+ EXTERNAL_NO_NAMESPACE_SCHEMA_LOCATION_PROPERTY,
+ externalNoNamespaceSchemaLocation);
+ }
+ }
+
+ // set entity resolver and error handler
+ if (entityResolver != null) {
+ parser.setEntityResolver(entityResolver);
+ }
+ if (errorHandler != null) {
+ parser.setErrorHandler(errorHandler);
+ }
+
+ // parse the document and return it
+ parser.parse(new InputSource(baStream));
+ } catch(SAXException e) {
+ if(true == Logger.isDebugEnabled() && null != buffer) {
+ String xmlContent = new String(buffer);
+ Logger.debug("SAXException in:\n" + xmlContent);
+ throw(e);
+ }
}
- if (errorHandler != null) {
- parser.setErrorHandler(errorHandler);
- }
-
- // parse the document and return it
- parser.parse(new InputSource(inputStream));
return parser.getDocument();
}