From 0149b093b73f401fb410c2b5c070bfcfc78499cc Mon Sep 17 00:00:00 2001 From: hns Date: Wed, 5 Jun 2002 17:45:38 +0000 Subject: [PATCH] made parsing more flexible by allowing InputSource parameter additionally to InputStream --- src/helma/objectmodel/dom/XmlUtil.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/helma/objectmodel/dom/XmlUtil.java b/src/helma/objectmodel/dom/XmlUtil.java index b28e8810..05301d70 100644 --- a/src/helma/objectmodel/dom/XmlUtil.java +++ b/src/helma/objectmodel/dom/XmlUtil.java @@ -14,6 +14,7 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; +import org.xml.sax.InputSource; import helma.objectmodel.INode; import helma.objectmodel.TransientNode; @@ -55,6 +56,19 @@ public class XmlUtil { } } + public static Document parse (InputSource in) throws RuntimeException { + DocumentBuilder d = getDocumentBuilder(); + try { + Document doc = d.parse (in); + doc.normalize(); + return doc; + } catch (SAXException e) { + throw new RuntimeException ("Bad xml-code: "+e.toString()); + } catch (IOException f) { + throw new RuntimeException ("Could not read Xml: "+f.toString()); + } + } + /** * get first "real" element (ie not the document-rootelement, but the next one */