Package org.w3c.dom

Examples of org.w3c.dom.Document


  {
    this.endpointId = endpointId;
  }

  public Document toXML() {
    Document ret=null;

    try {
      ret = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();

      org.w3c.dom.Element elem=ret.createElement(CLIENT_EPR_ELEMENT);
      elem.setAttribute("endpointId", endpointId);

      ret.appendChild(elem);
    } catch(Exception e) {
      e.printStackTrace();
    }

    return(ret);
View Full Code Here


    org.w3c.dom.Element ret=null;
   
    try {
      DocumentBuilder builder=DocumentBuilderFactory.newInstance().newDocumentBuilder();
     
      Document doc=builder.newDocument();
     
      ret = doc.createElement(TOP_LEVEL_ELEMENT_NAME);
     
    } catch(Exception e) {
      logger.error("Failed to create message", e);
    }
View Full Code Here

     */
    public static Document parse(InputStream 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) {
View Full Code Here

     */
    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) {
View Full Code Here

    Tidy tidy = new Tidy();
    tidy.setUpperCaseTags(false);
    tidy.setUpperCaseAttrs(false);
    tidy.setErrout(new PrintWriter(new NullWriter()));

    Document doc = tidy.parseDOM(bis,null);

    rewriteDOM(doc,input.getURL());

    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    tidy.pprint(doc,bos);
View Full Code Here

        if (!file.exists()) {
            throw new ObjectNotFoundException("IDGenerator not found in idgen.xml");
        }

        try {
            Document document = XmlUtil.parse(new FileInputStream(file));
            org.w3c.dom.Element tmp = (Element) document.getDocumentElement()
                    .getElementsByTagName("counter")
                    .item(0);

            return new XmlIDGenerator(Long.parseLong(XmlUtil.getTextContent(tmp)));
        } catch (Exception e) {
View Full Code Here

        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();
        return doc;
    }
View Full Code Here

        if(actual.length() == 0) {
            Assert.assertEquals(actual, expected);
        }
        actual = "<doc>" + actual + "</doc>";
        expected = "<doc>" + expected + "</doc>";
        Document actualDoc = buildDocument(new ByteArrayInputStream(actual.getBytes("UTF-8")));
        Document expectedDoc = buildDocument(new ByteArrayInputStream(expected.getBytes("UTF-8")));
        actual = null;
        expected = null;
        XMLAssert.assertXMLEqual(expectedDoc, actualDoc);
    }
View Full Code Here

        XMLAssert.assertXMLEqual(expectedDoc, actualDoc);
    }

    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);
View Full Code Here

    ArrayList arl = new ArrayList();

    try
    {
      filePath = path;
      Document qbXML = getDocumentFromString(xml);

      String idXML = getQBXMLName(qbXML);
      String nameQBXML = idXML.substring(0, idXML.length() - 5);

      NodeList list = qbXML.getElementsByTagName(nameQBXML + "AddRs");
      Node tmp = null;

      int requestID = 0;
      int length = list.getLength();
View Full Code Here

TOP

Related Classes of org.w3c.dom.Document

Copyright © 2018 www.massapicom. 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.