Package org.jdom

Examples of org.jdom.Element


    }
   
    public void testYOM()
        throws Exception
    {
        Document doc = new Document(new Element("root", "urn:test"));
       
        write(new JDOMWriter(doc.getRootElement()));
       
        testWrite(doc);
    }
View Full Code Here


        assertEquals(null, strings[1]);
        assertEquals("", strings[2]);
        reader.getXMLStreamReader().close();
       
        // Test writing
        Element element = new Element("strings", "t", "urn:test");
        Document doc = new Document(element);
        JDOMWriter writer = new JDOMWriter(element);
        type.writeObject(strings, writer, new MessageContext());
        writer.close();
   
View Full Code Here

        assertEquals(1, ints.length);
       
        reader.getXMLStreamReader().close();
       
        // Test writing
        Element element = new Element("ints", "t", "urn:test");
        Document doc = new Document(element);
        JDOMWriter writer = new JDOMWriter(element);
        type.writeObject(ints, writer, new MessageContext());
        writer.close();
View Full Code Here

        SimpleBean readBean = (SimpleBean) bt.readObject(new ElementReader(reader), new MessageContext());
        assertNotNull(readBean);
        assertEquals("bleh", readBean.getBleh());
        assertEquals("howdy", readBean.getHowdy());

        Element root = new Element("root");
        Element schema = new Element("schema");
        root.addContent(schema);

        Document doc = new Document(root);

        bt.writeSchema(schema);
View Full Code Here

        assertEquals("value2", m.get("key2"));
       
        reader.getXMLStreamReader().close();
       
        // Test writing
        Element element = new Element("map", "urn:test");
        Document doc = new Document(element);
        JDOMWriter writer = new JDOMWriter(element);
        type.writeObject(m, writer, new MessageContext());
        writer.close();

        assertValid("/t:map/t:entry[1]/t:key[text()='key1']", element);
        assertValid("/t:map/t:entry[1]/t:value[text()='value1']", element);

        assertValid("/t:map/t:entry[2]/t:key[text()='key2']", element);
        assertValid("/t:map/t:entry[2]/t:value[text()='value2']", element);

        Element types = new Element("types", Namespace.getNamespace("xsd", SoapConstants.XSD));
        Element schema = new Element("schema", Namespace.getNamespace("xsd", SoapConstants.XSD));
        types.addContent(schema);
       
        doc = new Document(types);
       
        type.writeSchema(schema);
View Full Code Here

        assertEquals(new QName("urn:Bean", "prop1"), prop1);

        System.out.println(info.getType(prop1));
        assertTrue(info.getType(prop1) instanceof StringType);
       
        Element root = new Element("root", Namespace.getNamespace("xsd", SoapConstants.XSD));
        new Document(root);
        Element schema = new Element("schema", Namespace.getNamespace("xsd", SoapConstants.XSD));
        root.addContent(schema);
        type.writeSchema(schema);

        addNamespace("xsd", SoapConstants.XSD);
        assertValid("//xsd:element[@name='prop1'][@type='xsd:string']", root);
View Full Code Here

    @Override
    public void writeSchema(Element root)
    {
        Namespace xsd = Namespace.getNamespace(SoapConstants.XSD_PREFIX, SoapConstants.XSD);
       
        Element simple = new Element("simpleType",xsd );
        simple.setAttribute(new Attribute("name", getSchemaType().getLocalPart()));
        root.addContent(simple);
       
        Element restriction = new Element("restriction", xsd);
        restriction.setAttribute(new Attribute("base", SoapConstants.XSD_PREFIX + ":string"));
        simple.addContent(restriction);
       
        Object[] constants = getTypeClass().getEnumConstants();

        for (Object constant : constants)
        {
            Element enumeration = new Element("enumeration", xsd);
            enumeration.setAttribute(new Attribute("value", ((Enum) constant).toString()));
            restriction.addContent(enumeration);
        }
    }
View Full Code Here

        String ns1 = "http://ns1.services.xfire.codehaus.org";
        String ns2 = "http://ns2.services.xfire.codehaus.org";
        String root = "http://services.xfire.codehaus.org";

        Element types = (Element) doc.getRootElement().getChildren("types", Namespace.getNamespace(WSDLWriter.WSDL11_NS)).get(0);
        String ns1p = NamespaceHelper.getPrefix(types, ns1);
        String ns2p = NamespaceHelper.getPrefix(types, ns2);
        String rootp = "r";

        addNamespace(ns1p, ns1);
View Full Code Here

    /**
     * Test marshalling an object into an existing Document with root Element.
     */
    public void testExistingDocumentWithRootNode() throws Exception {
        final JDOMContact0 contact = new JDOMContact0(FIRSTNAME, LASTNAME, PHONE);
        final Element rootElement = new Element("root");
        final Document existingDocument = new Document(rootElement);
       
        final Document returnedDocument = marshalActualDocument(contact, existingDocument);
        final Document expectedDocument = readExpectedOutput("test/extras/jdomDocumentContact0.xml");
       
View Full Code Here

    /**
     * Test marshalling an object into an existing Document with root and content Elements.
     */
    public void testExistingDocumentAndCurrentElement() throws Exception {
        final JDOMContact0 contact = new JDOMContact0(FIRSTNAME, LASTNAME, PHONE);
        final Element rootElement = new Element("root");
        final Element currentElement = new Element("current");
        rootElement.addContent(new Element("pre").setText("before current"));
        rootElement.addContent(currentElement);
        rootElement.addContent(new Element("post").setText("after current"));
        final Document existingDocument = new Document(rootElement);
       
        final Document returnedDocument = marshalActualDocument(contact, currentElement);
        final Document expectedDocument = readExpectedOutput("test/extras/jdomElementContact0.xml");
               
View Full Code Here

TOP

Related Classes of org.jdom.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.