Author: norman.richards(a)jboss.com
Date: 2008-01-29 01:20:52 -0500 (Tue, 29 Jan 2008)
New Revision: 7278
Modified:
trunk/src/main/org/jboss/seam/util/XML.java
Log:
JBSEAM-2194
Modified: trunk/src/main/org/jboss/seam/util/XML.java
===================================================================
--- trunk/src/main/org/jboss/seam/util/XML.java 2008-01-29 04:04:35 UTC (rev 7277)
+++ trunk/src/main/org/jboss/seam/util/XML.java 2008-01-29 06:20:52 UTC (rev 7278)
@@ -1,8 +1,10 @@
package org.jboss.seam.util;
import java.io.ByteArrayInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+import java.net.UnknownHostException;
import org.dom4j.DocumentException;
import org.dom4j.Element;
@@ -13,13 +15,28 @@
public class XML
{
- public static Element getRootElement(InputStream stream) throws DocumentException
- {
- SAXReader saxReader = new SAXReader();
- saxReader.setEntityResolver(new DTDEntityResolver());
- saxReader.setMergeAdjacentText(true);
- return saxReader.read(stream).getRootElement();
- }
+ public static Element getRootElement(InputStream stream) throws DocumentException
+ {
+ try {
+ SAXReader saxReader = new SAXReader();
+ saxReader.setEntityResolver(new DTDEntityResolver());
+ saxReader.setMergeAdjacentText(true);
+ return saxReader.read(stream).getRootElement();
+ } catch (DocumentException e) {
+ Throwable nested = e.getNestedException();
+ if (nested!= null) {
+ if (nested instanceof FileNotFoundException) {
+ throw new RuntimeException("Can't find schema/DTD reference:
" +
+ nested.getMessage(), e);
+ } else if (nested instanceof UnknownHostException) {
+ throw new RuntimeException("Cannot connect to host from
schema/DTD reference: " +
+ nested.getMessage() +
+ " - check that your schema/DTD reference is
current", e);
+ }
+ }
+ throw e;
+ }
+ }
/**
Show replies by date