16 package net.squiz.matrix.core;
18 import javax.xml.transform.stream.StreamSource;
19 import javax.xml.parsers.*;
20 import org.w3c.dom.Document;
21 import org.xml.sax.SAXException;
34 private static DocumentBuilder builder;
44 public static DocumentBuilder
getParser() throws SAXException {
46 if (builder == null) {
48 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
49 factory.setIgnoringElementContentWhitespace(
false);
50 builder = factory.newDocumentBuilder();
51 }
catch (ParserConfigurationException pce) {
52 throw new SAXException(
"Error creating the document builder : "
72 throw new SAXException(
"Input Stream of XML source cannot be null");
76 }
catch (IOException se) {
77 throw new SAXException(
"Could not create the document from the " +
78 "Input Stream : " + se.getMessage());
81 if (doc.getDocumentElement().getTagName().equals(
"error"))
82 throw new SAXException(
"Could not create the document");
97 byte [] xmlArray = xmlStr.getBytes();
98 ByteArrayInputStream xmlStream =
new ByteArrayInputStream(xmlArray);
100 StreamSource ss =
new StreamSource(xmlStream);
105 }
catch (SAXException se) {
106 throw new SAXException(
"Could not create document from String: "