made parsing more flexible by allowing InputSource
parameter additionally to InputStream
This commit is contained in:
parent
cdc0fb82f2
commit
0149b093b7
1 changed files with 14 additions and 0 deletions
|
@ -14,6 +14,7 @@ import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
|
||||||
import helma.objectmodel.INode;
|
import helma.objectmodel.INode;
|
||||||
import helma.objectmodel.TransientNode;
|
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
|
* get first "real" element (ie not the document-rootelement, but the next one
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue