Package com.volantis.mcs.dom

Examples of com.volantis.mcs.dom.Element


        return tr;
    }

    protected Element createTable(Element rows []) {
        Element table = domFactory.createElement();
        table.setName("table");
        for(int i=0; i<rows.length; i++) {
            table.addTail(rows[i]);
        }

        return table;
    }
View Full Code Here


     */
    public void testCreateElementFromStringGoodXML() throws Exception {
        String xml = "<prompt>well formed xml</prompt>";
        VoiceXMLRoot protocol = (VoiceXMLRoot) createTestableProtocol(
                internalDevice);
        Element element = protocol.createElementFromString(xml);
        assertEquals("prompt", element.getName());
        Text text = (Text) element.getHead();
        String contents = new String(text.getContents(), 0,
                                     text.getLength());
        assertEquals("well formed xml", contents);
    }
View Full Code Here

        return table;
    }

    protected Element createTable(int rows, int[] columns) {
        Element table = domFactory.createElement();
        table.setName("table");
        int maxColumns = 0;
        int col = 0;
        for(int row = 0; row < rows; row++) {
            Element tr = domFactory.createElement();
            tr.setName("tr");
            table.addTail(tr);
            col = 0;
            for(; col < columns[row]; col++) {
                Element td = domFactory.createElement();
                td.setName("td");
                Element p = domFactory.createElement();
                p.setName("BLOCK");
                td.addTail(p);
                Text text = domFactory.createText();
                text.append("r");
                text.append(new Integer(row).toString());
                text.append(", c");
                text.append(new Integer(col).toString());
                p.addTail(text);
                tr.addTail(td);
            }
            if(col > maxColumns) {
                maxColumns = col;
            }
View Full Code Here

    /**
     * Test that fixTable in transformElement() works with other
     * transformations.
     */
    public void testTransformElementFixTableFromParagraph() throws Exception {
        Element p = domFactory.createElement();
        p.setName(WMLConstants.BLOCH_ELEMENT);
        int[] columns = {1, 1};
        Element table = createTable(2, columns);
        p.addTail(table);

        Document doc = domFactory.createDocument();
        doc.addNode(p);       
        transformer.transformElement(p);
View Full Code Here

    /**
     * Test that fixTable in transformElement() works with other
     * transformations.
     */
    public void testTransformElementFromWml() throws Exception {
        Element wml = domFactory.createElement();
        wml.setName("wml");
        Element card = domFactory.createElement();
        card.setName("card");
        wml.addTail(card);

        Element td []= new Element[1];
        td[0] = createTableCell("cell", false, false, 1);
        Element tr [] = new Element[1];
        tr[0] = createRow(td);
        Element table = createTable(tr);
        card.addTail(table);

        Document doc = domFactory.createDocument();
        doc.addNode(wml);

View Full Code Here

     * should be transformed to remove the outer table but keep the inner
     * table and move the paragraphs in the rows out to be a single paragraph
     * surrounding the inner table.
     */
    public void testTransformElementNestedTablesFromWml1() throws Exception {
        Element wml = domFactory.createElement();
        wml.setName("wml");
        Element card = domFactory.createElement();
        card.setName("card");
        wml.addTail(card);

        Element td [] = new Element[1];
        td[0] = createTableCell("cell", false, false, 1);
        Element tr [] = new Element[2];
        tr[0] = createRow(td);
        td = new Element[1];
        int cols [] = {2, 3, 1};
        td[0] = domFactory.createElement("td");
        td[0].addTail(createTable(3, cols));
        tr[1] = createRow(td);
        Element table = createTable(tr);
        card.addTail(table);

        Document doc = domFactory.createDocument();
        doc.addNode(wml);
        transformer.transformElement(wml);
View Full Code Here

     * transformations. In this case a 1 column table containing a paragraph
     * in one row and a 1 column table in another whose rows are paragraphed
     * should be transformed to remove both tables.
     */
    public void testTransformElementNestedTablesFromWml2() throws Exception {
        Element wml = domFactory.createElement();
        wml.setName("wml");
        Element card = domFactory.createElement();
        card.setName("card");
        wml.addTail(card);

        Element td [] = new Element[1];
        td[0] = createTableCell("cell", false, false, 1);
        Element tr [] = new Element[2];
        tr[0] = createRow(td);
        td = new Element[1];
        int cols [] = {1, 1};
        td[0] = domFactory.createElement("td");
        td[0].addTail(createTable(2, cols));
        tr[1] = createRow(td);
        Element table = createTable(tr);
        card.addTail(table);

        Document doc = domFactory.createDocument();
        doc.addNode(wml);
        transformer.transformElement(wml);
View Full Code Here

     * should be transformed to remove both tables. This is the same as
     * testTransformElementNestedTablesFromWml2 except the outer table
     * first row contains three nested paragraphs.
     */
    public void testTransformElementNestedTablesFromWml3() throws Exception {
        Element wml = domFactory.createElement();
        wml.setName("wml");
        Element card = domFactory.createElement();
        card.setName("card");
        wml.addTail(card);

        Element td [] = new Element[1];
        td[0] = createTableCell("cell", true, true, 3);
        Element tr [] = new Element[2];
        tr[0] = createRow(td);
        td = new Element[1];
        int cols [] = {1, 1};
        td[0] = domFactory.createElement("td");
        td[0].addTail(createTable(2, cols));
        tr[1] = createRow(td);
        Element table = createTable(tr);
        card.addTail(table);

        Document doc = domFactory.createDocument();
        doc.addNode(wml);
        transformer.transformElement(wml);
View Full Code Here

     * transformations. In this case a 2 column table containing a paragraph
     * in one row and a 1 column table in another whose rows are paragraphed
     * should be transformed to remove the inner table.
     */
    public void testTransformElementNestedTablesFromWml4() throws Exception {
        Element wml = domFactory.createElement();
        wml.setName("wml");
        Element card = domFactory.createElement();
        card.setName("card");
        wml.addTail(card);

        Element td [] = new Element[2];
        td[0] = createTableCell("cell", false, false, 1);
        td[1] = createTableCell("cell", true, false, 2);
        Element tr [] = new Element[2];
        tr[0] = createRow(td);
        td = new Element[1];
        int cols [] = {1, 1};
        td[0] = domFactory.createElement("td");
        td[0].addTail(createTable(2, cols));
        tr[1] = createRow(td);
        Element table = createTable(tr);
        card.addTail(table);

        Document doc = domFactory.createDocument();
        doc.addNode(wml);
        transformer.transformElement(wml);
View Full Code Here

     * Test that a paragraph containing a 2 column table with no
     * nesting and no column attribute does not change apart from the
     * addition of the correct column attribute.
     */
    public void testFixGridTable2ColumnTable() throws Exception {
        Element p = domFactory.createElement();
        p.setName("BLOCK");
        int[] columns = {2, 2};
        Element table = createTable(2, columns);
        p.addTail(table);

        // the expected table should contain the column attribute
        table.setAttribute("columns", "2");
        Document doc = domFactory.createDocument();
        doc.addNode(p);
        String expected = DOMUtilities.toString(doc);

        // the table to fix should not...
        table.removeAttribute("columns");

        transformer.fixTable(table);

        assertEquals(expected, DOMUtilities.toString(doc));
    }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.dom.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.