Package com.google.gwt.xml.client

Examples of com.google.gwt.xml.client.Element


     * Generate xml elements of kill node and attach them to xml doc
     */
    public void generateXML(Document doc, Element root, NodeWidget next) {

        // create <kill>
        Element action = doc.createElement("kill");
        root.appendChild(action);
        action.setAttribute("name", name.getText());

        // create <message>
        action.appendChild(generateElement(doc, "message", message));
    }
View Full Code Here


    /**
     * Generate xml elements of fork node and attach them to xml doc
     */
    public void generateXML(Document doc, Element root, NodeWidget next) {

        Element action = doc.createElement("fork");
        action.setAttribute("name", name.getText());
        for (NodeWidget w : neighbors) {
            Element pathEle = doc.createElement("path");
            pathEle.setAttribute("start", w.getName());
            action.appendChild(pathEle);
        }
        root.appendChild(action);

    }
View Full Code Here

     * Generate xml elements of start node and attach them to xml doc
     */
    public void generateXML(Document doc, Element root, NodeWidget next) {

        // create <start>
        Element action = doc.createElement("start");
        action.setAttribute("to", okVal.getName());
    }
View Full Code Here

    /**
     * Generate xml elements of join node and attach them to xml doc
     */
    public void generateXML(Document doc, Element root, NodeWidget next) {

        Element action = doc.createElement("join");
        action.setAttribute("name", name.getText());
        action.setAttribute("to", next.getName());
        root.appendChild(action);

    }
View Full Code Here

     */
    @Deprecated
    public void DTOtoXML(SongDTO brano) {

        // create the new song node
        Element song = document.createElement(SONG_NAME);
        // append the filename
        Element fileName = document.createElement(FILE_NAME);
        fileName.appendChild(document.createCDATASection(brano.getFile()));
        song.appendChild(fileName);
        // fill the new node with data.
        Element albumTitle = document.createElement(ALBUMTITLE_NAME);
        albumTitle.appendChild(document.createCDATASection(brano.getAlbum()));
        song.appendChild(albumTitle);

        Element authorComposer = document.createElement(AUTHORCOMPOSER_NAME);
        authorComposer.appendChild(document.createCDATASection(brano
                .getComposer()));
        song.appendChild(authorComposer);

        Element leadArtist = document.createElement(LEADARTIST_NAME);
        leadArtist.appendChild(document.createTextNode(brano.getArtist()));
        leadArtist.appendChild(document.createCDATASection(brano.getArtist()));
        song.appendChild(leadArtist);

        Element songGenre = document.createElement(SONGGENRE_NAME);
        songGenre.appendChild(document.createCDATASection(brano.getGenre()));
        song.appendChild(songGenre);

        Element songTitle = document.createElement(SONGTITLE_NAME);
        songTitle.appendChild(document.createCDATASection(brano.getTitle()));
        song.appendChild(songTitle);

        Element trackNumber = document.createElement(TRACKNUMBER_NAME);
        trackNumber.appendChild(document.createCDATASection(brano
                .getTrackNumber()));
        song.appendChild(trackNumber);

        Element year = document.createElement(YEAR_NAME);
        year.appendChild(document.createCDATASection(brano.getYear()));
        song.appendChild(year);

        // add the new node to the tree
        root.appendChild(song);
    };
View Full Code Here

     * @return
     */
    private SongDTO generateDTO(Element node) {
        SongDTO song = new SongDTO();
        while (node.hasChildNodes()) {
            Element child = (Element) node.getFirstChild();
            String name = child.getNodeName();
            // System.out.println(child.getFirstChild().getNodeValue());
            // if (name.equals(FILE_NAME))
            // song.setFile(clearFileName(child.getFirstChild().getNodeValue()));
            if (name.equals(FILE_NAME))
                song.setFile(child.getFirstChild().getNodeValue());
            else if (name.equals(ALBUMTITLE_NAME))
                song.setAlbum(child.getFirstChild().getNodeValue());
            else if (name.equals(AUTHORCOMPOSER_NAME))
                song.setComposer(child.getFirstChild().getNodeValue());
            else if (name.equals(LEADARTIST_NAME))
                song.setArtist(child.getFirstChild().getNodeValue());
            else if (name.equals(SONGGENRE_NAME))
                song.setGenre(child.getFirstChild().getNodeValue());
            else if (name.equals(SONGTITLE_NAME))
                song.setTitle(child.getFirstChild().getNodeValue());
            else if (name.equals(TRACKNUMBER_NAME))
                song.setTrackNumber(child.getFirstChild().getNodeValue());
            else if (name.equals(YEAR_NAME))
                song.setYear(child.getFirstChild().getNodeValue());
            node.removeChild(child);
        }
        return song;
    }
View Full Code Here

    NodeList list = doc.getElementsByTagName(modelType.getRecordName());
    ArrayList<ModelData> records = new ArrayList<ModelData>();
    for (int i = 0; i < list.getLength(); i++) {
      Node node = list.item(i);
      Element elem = (Element) node;
      ModelData model = newModelInstance();
      for (int j = 0; j < modelType.getFieldCount(); j++) {
        DataField field = modelType.getField(j);
        Class type = field.getType();
        String name = field.getName();
View Full Code Here

    NodeList list = doc.getElementsByTagName(modelType.getRecordName());
    ArrayList<ModelData> records = new ArrayList<ModelData>();
    for (int i = 0; i < list.getLength(); i++) {
      Node node = list.item(i);
      Element elem = (Element) node;
      ModelData model = newModelInstance();
      for (int j = 0; j < modelType.getFieldCount(); j++) {
        DataField field = modelType.getField(j);
        Class type = field.getType();
        String name = field.getName();
View Full Code Here

      // Act
      Document document = XMLParser.parse(xmlContent);

      // Assert
      Element documentElement = document.getDocumentElement();
      assertEquals("beans", documentElement.getTagName());

      Element beans = (Element) document.getFirstChild();
      assertEquals("beans", beans.getTagName());
      assertNull(beans.getNextSibling());
      assertNull(beans.getPreviousSibling());

      Element testBean = document.getElementById("testBean");
      NodeList beanList = document.getElementsByTagName("bean");

      assertEquals(2, beanList.getLength());
      assertEquals("testBean", beanList.item(0).getAttributes().getNamedItem("id").getNodeValue());
      assertEquals("bean", testBean.getTagName());
      assertEquals("bean", testBean.getNodeName());
      assertEquals("http://www.springframework.org/schema/beans", testBean.getNamespaceURI());
      assertEquals("org.springframework.beans.TestBean", testBean.getAttribute("class"));
      assertTrue(testBean.hasAttribute("class"));
      assertFalse(testBean.hasAttribute("fooAttr"));
      Attr classAttr = testBean.getAttributeNode("class");
      assertEquals("class", classAttr.getName());
      assertEquals("org.springframework.beans.TestBean", classAttr.getValue());
      assertEquals("http://www.springframework.org/schema/beans", classAttr.getNamespaceURI());
      assertEquals("class", classAttr.getNodeName());
      // CDATA attribute
      Element ageProperty = (Element) testBean.getChildNodes().item(0);
      assertEquals(1, ageProperty.getAttributes().getLength());
      assertEquals("age", ageProperty.getAttribute("name"));
      assertEquals("<10>", ageProperty.getNodeValue());
      // TODO : pass this assertion
      // assertEquals("#cdata-section",
      // ageProperty.getFirstChild().getNodeName());

      // "spouse" child bean assertions
      NamedNodeMap innerBeanAgePropertyAttributes = beanList.item(1).getChildNodes().item(0).getAttributes();
      assertEquals("age", innerBeanAgePropertyAttributes.getNamedItem("name").getNodeValue());
      assertEquals("11", innerBeanAgePropertyAttributes.getNamedItem("value").getNodeValue());

      // bean from "util" namespace
      Element name = (Element) testBean.getNextSibling();
      assertEquals("property-path", name.getTagName());
      assertEquals("property-path", name.getNodeName());
      assertEquals("http://www.springframework.org/schema/util", name.getNamespaceURI());

   }
View Full Code Here

   @Test
   public void removeWhitespace() throws Exception {
      // Arrange
      Document document = XMLParser.createDocument();
      Element child = document.createElement("child");
      child.setNodeValue("     ");
      document.appendChild(child);
      Element child2 = document.createElement("child");
      child2.appendChild(document.createCDATASection("    "));
      document.appendChild(child2);

      // Pre-Assert : empty TextNode should exists
      assertEquals(1, child.getChildNodes().getLength());
      assertEquals(1, child2.getChildNodes().getLength());

      // Act
      XMLParser.removeWhitespace(document);

      // Assert
      assertEquals(0, child.getChildNodes().getLength());
      // empty cdata is not removed
      assertEquals(1, child2.getChildNodes().getLength());
   }
View Full Code Here

TOP

Related Classes of com.google.gwt.xml.client.Element

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.