Package org.w3c.dom

Examples of org.w3c.dom.Document


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


      // 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();
      NodeList accountElems = accountsElem.getElementsByTagName("account");
      for (int i = 0, n = accountElems.getLength(); i < n; i++) {
        Element accountElem = (Element) accountElems.item(i);
        // create account, assign initial balance
        String customerName = accountElem.getAttribute("holder");
View Full Code Here

        System.out.println("Ok, SAX factory JAXP creates is: "+spf);
        System.out.println("Let's parse...");
        spf.newSAXParser().parse(f, new org.xml.sax.helpers.DefaultHandler());
        System.out.println("Done. And then DOM build:");

        Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(f);

        System.out.println("Succesfully built DOM tree from '"+f+"', -> "+doc);
    }
View Full Code Here

    }

    @Test
    public void testFirstElement() throws Exception {
        String str = "<root>dflg<firstelement/></root>";
        Document doc = Helper.getAsDocument(str);
        Node root = Helper.getFirstElement(doc.getElementsByTagName("root"));
        assertEquals(root.getNodeName(), "root");

        assertEquals(
                Helper.getFirstElement(root.getChildNodes()).getNodeName(),
                "firstelement");
View Full Code Here

  @Test
  public void testParse() throws Exception {
    ResourceLoader loader = new ResourceLoader();
    URL url = loader.getResource("dozerBeanMapping.xml");

    Document document = XMLParserFactory.getInstance().createParser().parse(url.openStream());
    parser = new XMLParser(document);

    MappingFileData mappings = parser.load();
    assertNotNull(mappings);
  }
View Full Code Here

  @Test
  public void testParseCustomConverterParam() throws Exception {
    ResourceLoader loader = new ResourceLoader();
    URL url = loader.getResource("fieldCustomConverterParam.xml");

    Document document = XMLParserFactory.getInstance().createParser().parse(url.openStream());
    parser = new XMLParser(document);
   
    MappingFileData mappings = parser.load();

    assertNotNull("The mappings should not be null", mappings);
View Full Code Here

        properties.put("javafx_home", "C:\\Program Files\\NetBeans 6.5\\javafx2\\javafx-sdk");

        Set<File> files = new FastSet<File>();
        files.add(new File(mavenRepoPath + "\\de\\timefinder\\timefinder-core\\2009-v1\\timefinder-core-2009-v1.jar"));

        Document doc = doc = Helper.parse(new FileInputStream("../pom.xml"));
        fillProperties(doc);
        fillDependencies(files, doc);

        doc = Helper.parse(new FileInputStream("pom.xml"));
        fillProperties(doc);
View Full Code Here

    public List<JavaOneInterval> parse(InputStream is) throws Exception {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setValidating(false);
        factory.setNamespaceAware(false);
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document doc = builder.parse(is);
        return parse(doc);
    }
View Full Code Here

    this.targetFile = targetFile;
  }

  public void run() throws Exception {
    DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
    Document tml = builder.parse(tmlFile);
    this.tld = builder.newDocument();
   
    Element taglib = createElement("taglib");
    taglib.setAttribute("xmlns", "http://java.sun.com/xml/ns/j2ee");
    taglib.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
    taglib.setAttribute("xsi:schemaLocation", "http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd");
    tld.appendChild(taglib);
   
    appendElement(taglib, "tlibversion", "4.0");
    appendElement(taglib, "jspversion", "2.0");
    appendElement(taglib, "shortname", "WebTML");
   
    NodeList groups = tml.getElementsByTagName("attributeGroup");
    for(int i = 0; i < groups.getLength(); i++) {
      Element group = (Element) groups.item(i);
      String name = childText(group, "name");
      attributeGroups.put(name, group.getElementsByTagName("attribute"));
    }
   
    NodeList tags = tml.getElementsByTagName("tag");
    for(int i = 0; i < tags.getLength(); i++) {
      Element tmlTag = (Element) tags.item(i);
      String name = childText(tmlTag, "name");
      copyTag(name, tmlTag, appendElement(taglib, "tag"));
      Element aliases = (Element) tmlTag.getElementsByTagName("aliases").item(0);
View Full Code Here

    public MappingDocument loadDocument(InputStream stream) throws MappingException {
        try {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setValidating(false);
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document doc = db.parse(stream);
            return loadContents(doc);
        } catch (IOException e) {
            throw new MappingException(e);
        } catch (ParserConfigurationException e) {
          throw new MappingException(e);
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.