Examples of DocumentBuilder


Examples of javax.xml.parsers.DocumentBuilder

     * @return ...
     *
     * @throws RuntimeException ...
     */
    public static Document parse(InputStream in) throws RuntimeException {
        DocumentBuilder d = getDocumentBuilder();

        try {
            Document doc = d.parse(in);

            doc.normalize();

            return doc;
        } catch (SAXException e) {

Examples of javax.xml.parsers.DocumentBuilder

     * @return ...
     *
     * @throws RuntimeException ...
     */
    public static Document parse(InputSource in) throws RuntimeException {
        DocumentBuilder d = getDocumentBuilder();

        try {
            Document doc = d.parse(in);

            doc.normalize();

            return doc;
        } catch (SAXException e) {

Examples of javax.xml.parsers.DocumentBuilder

                                    ParserConfigurationException {
        if (domBuilderFactory == null) {
            domBuilderFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
        }

        DocumentBuilder parser = domBuilderFactory.newDocumentBuilder();
        Document doc;

        if (obj instanceof String) {
            try {
                // first try to interpret string as URL
                new URL(obj.toString());

                doc = parser.parse(obj.toString());
            } catch (MalformedURLException nourl) {
                // if not a URL, maybe it is the XML itself
                doc = parser.parse(new InputSource(new StringReader(obj.toString())));
            }
        } else if (obj instanceof InputStream) {
            doc = parser.parse(new InputSource((InputStream) obj));
        } else if (obj instanceof Reader) {
            doc = parser.parse(new InputSource((Reader) obj));
        } else {
            throw new RuntimeException("Unrecognized argument to parseXml: " + obj);
        }

        doc.normalize();

Examples of javax.xml.parsers.DocumentBuilder

    private static Document buildDocument(InputStream is) {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        final Document doc;
        try {
            DocumentBuilder db = dbf.newDocumentBuilder();
            doc = db.parse(is);
        } catch (Exception e) {
            throw new IllegalStateException("buildDocument failed!", e);
        }
        return doc;
    }

Examples of javax.xml.parsers.DocumentBuilder

    {

      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      factory.setNamespaceAware(true);
      factory.setValidating(true);
      DocumentBuilder builder = factory.newDocumentBuilder();

      ErrorHandler errorHandler = new ErrorHandler() {

        public void warning(org.xml.sax.SAXParseException e)
        {
        //  System.err.println("Warning : " + e.getMessage());
        }

        public void error(org.xml.sax.SAXParseException e)
        {
        // System.err.println("Error : " + e.getMessage());
        }

        public void fatalError(org.xml.sax.SAXParseException e)
        {
        //  System.err.println("FatalError : " + e.getMessage());
        }
      };
      builder.setErrorHandler(errorHandler);

      if (xml.substring(xml.length() - 3, xml.length()).equals("xml"))
      {
        returnDocument = builder.parse(new File(filePath + xml));
      } else
      {
        InputStream in = new BufferedInputStream(new StringBufferInputStream(xml));
        returnDocument = builder.parse(in);
      }
    } catch (IOException e)
    {
      logger.error("[getDocumentFromString] Exception thrown.", e);
    } catch (ParserConfigurationException e)

Examples of javax.xml.parsers.DocumentBuilder

        Document doc;
        try {
            // read the schema to DOM representation
            DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
            fact.setNamespaceAware(true);
            DocumentBuilder bldr = fact.newDocumentBuilder();
            doc = bldr.parse(m_wsdlProvider.getWSDL(req));
            Element schema = doc.getDocumentElement();
            NodeList services = schema.getElementsByTagNameNS(WSDLSOAP_NAMESPACE, "address");
            for (int i = 0; i < services.getLength(); i++) {
                Node node = services.item(i).getAttributes().getNamedItem("location");
                if (node != null) {

Examples of javax.xml.parsers.DocumentBuilder

  public static String parse(InputStream in)
  {
    try {


      DocumentBuilder builder =
          DocumentBuilderFactory.newInstance().newDocumentBuilder();
      Document doc = builder.parse(in);
      Element root = doc.getDocumentElement();

      normalize(root);

      ByteArrayOutputStream bout = new ByteArrayOutputStream();

Examples of javax.xml.parsers.DocumentBuilder

    m_response = faultResp;
    m_faultName = faultName;
  }

  public TestBPELEngine(String resp) throws Exception {
    DocumentBuilder builder=DocumentBuilderFactory.newInstance().newDocumentBuilder();
   
    java.io.InputStream is=new java.io.ByteArrayInputStream(resp.toString().getBytes());
   
    Document doc=builder.parse(is);
   
    is.close();
   
    m_response = doc.getDocumentElement();
  }

Examples of javax.xml.parsers.DocumentBuilder

  }

  private static Map<String, Double> loadAccounts(String resourceName) {
    try {
      // parse the accounts document
      DocumentBuilder domBuilder =
          DocumentBuilderFactory.newInstance().newDocumentBuilder();
      URL resource = AccountSystem_Impl.class.getResource(resourceName);
      if (resource == null) return Collections.emptyMap();
      Document accountsDocument = domBuilder.parse(resource.toString());
      // give everyone an initial balance of $50
      Double initialBalance = new Double(50);
      // iterate over the accounts
      Map<String, Double> accounts = new HashMap<String, Double>();
      Element accountsElem = accountsDocument.getDocumentElement();

Examples of javax.xml.parsers.DocumentBuilder

    public static DocumentBuilder newDocumentBuilder()
            throws ParserConfigurationException {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setValidating(false);
        factory.setNamespaceAware(false);
        DocumentBuilder builder = factory.newDocumentBuilder();

        return builder;
    }
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.