Utility method to build a Document using the control DocumentBuilder
to parse the specified String.
@param fromXML
@return Document representation of the String content
@throws SAXException
@throws IOException
15995
public static Document buildControlDocument(String fromXML)
        throws SAXException, IOException {
        return buildDocument(newControlParser(), new StringReader(fromXML));
    }
965384
public synchronized Node parse(InputStream in) throws IOException,SAXException
    {
        Handler handler=new Handler();
        XMLReader reader=_parser.getXMLReader();
        reader.setContentHandler(handler);
        reader.setErrorHandler(handler);
        reader.setEntityResolver(handler);
        _parser.parse(new InputSource(in),handler);
        if(handler._error!=null)
            throw handler._error;
        Node doc=(Node)handler._top.get(0);
        handler.clear();
        return doc;
    }
1016370
function XmlDocument(xml) {
  xml && (xml = xml.toString().trim());

  if (!xml)
    throw new Error("No XML to parse!");

  // Expose the parser to the other delegates while the parser is running
  this.parser = sax.parser(true); // strict
  addParserEvents(this.parser);

  // We'll use the file-scoped "delegates" var to remember what elements we're currently
  // parsing; they will push and pop off the stack as we get deeper into the XML hierarchy.
  // It's safe to use a global because JS is single-threaded.
  delegates = [this];
  
  this.parser.write(xml);

  // Remove the parser as it is no longer needed and should not be exposed to clients
  delete this.parser;
}
481836
public Document parse(File file) throws SAXException, IOException
    {
        return verify(_WrappedBuilder.parse(file));
    }
636292
public ConfigBase fromXml(final InputStream is,
                            final Class cl) throws ConfigException {
    try {
      return fromXml(parseXml(is), cl);
    } catch (final ConfigException ce) {
      throw ce;
    } catch (final Throwable t) {
      throw new ConfigException(t);
    }
  }
487361
public synchronized Node parse(InputSource source) throws IOException,SAXException
    {
        Handler handler=new Handler();
        XMLReader reader=_parser.getXMLReader();
        reader.setContentHandler(handler);
        reader.setErrorHandler(handler);
        reader.setEntityResolver(handler);
        if(log.isDebugEnabled())
            log.debug("parsing: sid="+source.getSystemId()+",pid="+source.getPublicId());
        _parser.parse(source,handler);
        if(handler._error!=null)
            throw handler._error;
        Node doc=(Node)handler._top.get(0);
        handler.clear();
        return doc;
    }
2251
public static String toXml(com.greenpepper.document.Document document) throws IOException
	{
		StringWriter sw = new StringWriter();

		XmlReport xmlReport = XmlReport.newInstance("");
		xmlReport.generate( document );
		xmlReport.printTo( sw );

		return sw.toString();
	}
297989
public static DomDocument parseInputStream(DocumentBuilderFactory documentBuilderFactory, InputStream inputStream) {

    try {
      DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
      documentBuilder.setErrorHandler(new DomErrorHandler());
      return new DomDocumentImpl(documentBuilder.parse(inputStream));
    } catch (ParserConfigurationException e) {
      throw new ModelParseException("ParserConfigurationException while parsing input stream", e);

    } catch (SAXException e) {
      throw new ModelParseException("SAXException while parsing input stream", e);

    } catch (IOException e) {
      throw new ModelParseException("IOException while parsing input stream", e);

    }
  }
574730
public Document parse(InputSource inputsource) throws SAXException, IOException
    {
        return verify(_WrappedBuilder.parse(inputsource));
    }
153455
public synchronized Node parse(String xml) throws IOException, SAXException {
        ByteArrayInputStream is = new ByteArrayInputStream(xml.getBytes());
        return parse(is);
    }
1140157
public static Document buildDocument(DocumentBuilder withBuilder,
                                         Reader fromReader) throws SAXException, IOException {
        return buildDocument(withBuilder, new InputSource(fromReader));
    }
822988
public InputStream getBuilderXML() throws IOException {
        return builderXMLPath == null ?
            Configuration.class.getResourceAsStream(DEFAULT_BUILDER_XML) :
            DocFile.createFileForInput(this, builderXMLPath).openInputStream();
    }
1148530
public static Element parse(InputStream xmlStream) throws IOException
   {
      DocumentBuilder builder = getDocumentBuilder();
      return parse(xmlStream, builder);
   }
1221257
public static Document readXML(InputSource source) {
		final DocumentBuilder builder = createDocumentBuilder();
		try {
			return builder.parse(source);
		} catch (Exception e) {
			throw new UtilException(e, "Parse XML from stream error!");
		}
	}
1191939
public Document parseString(String text) throws SAXException {
        try {
            return parse(new InputSource(new StringReader(text)));
        } catch (IOException e) {
            throw new RuntimeException("unexpected world exception while reading memory stream", e);
        }
    }
388396
public NodeConfig parser(InputStreamReader xml) throws UnmarshalException {

		NodeConfig config = new NodeConfig();
		SAXBuilder builder = new SAXBuilder(false);
		Document doc = null;

		try {
			doc = builder.build(xml);
			config = parserNode(doc.getRootElement());

			xml.close();
			return config;
		} catch (JDOMException e) {
			throw new UnmarshalException(e);
		} catch (IOException e) {
			throw new UnmarshalException(e);
		}
	}
1372325
public static Document getDocument(InputStream inputStream) {
        Document result = null;

        try {
            // memory optimization over minor performance sacrifice
            synchronized (XmlRepositoryFactory.class) {
                if (documentBuilder == null) {
                    documentBuilder = builderFactory.newDocumentBuilder();
                }

                result = documentBuilder.parse(inputStream);
            }
        } catch (ParserConfigurationException ex) {
            throw new MjdbcRuntimeException(ex);
        } catch (SAXException ex) {
            throw new MjdbcRuntimeException(ex);
        } catch (IOException ex) {
            throw new MjdbcRuntimeException(ex);
        }

        return result;
    }