Package org.restlet.ext.xml

Examples of org.restlet.ext.xml.DomRepresentation


        final Response response = client.handle(request);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        response.getEntity().write(System.out);
        System.out.println();

        final DomRepresentation dom = new DomRepresentation(
                response.getEntity());
        for (final Node node : dom.getNodes("/emails/email")) {
            final NamedNodeMap attrs = node.getAttributes();
            final String href = attrs.getNamedItem("href").getNodeValue();
            printMail(client, baseUri, href);
        }
View Full Code Here


     * @param errorCode
     *            the error code.
     */
    private Representation generateErrorRepresentation(String errorMessage,
            String errorCode) {
        DomRepresentation result = null;
        // This is an error
        // Generate the output representation
        try {
            result = new DomRepresentation(MediaType.TEXT_XML);
            // Generate a DOM document representing the list of
            // items.
            Document d = result.getDocument();

            Element eltError = d.createElement("error");

            Element eltCode = d.createElement("code");
            eltCode.appendChild(d.createTextNode(errorCode));
View Full Code Here

     * Returns a listing of all registered items.
     */
    public Representation toXml() {
        // Generate the right representation according to its media type.
        try {
            DomRepresentation representation = new DomRepresentation(
                    MediaType.TEXT_XML);

            // Generate a DOM document representing the list of
            // items.
            Document d = representation.getDocument();
            Element r = d.createElement("items");
            d.appendChild(r);
            for (Item item : getItems().values()) {
                Element eltItem = d.createElement("item");

View Full Code Here

    public List<S3Bucket> getBuckets() {
        List<S3Bucket> result = new ArrayList<S3Bucket>();

        // Fetch a resource: an XML document with our list of buckets
        Response response = authorizedGet(HOST);
        DomRepresentation document = new DomRepresentation(response.getEntity());

        if (response.getStatus().isSuccess()) {
            // Use XPath to find the bucket names
            for (Node node : document.getNodes("//Bucket/Name")) {
                result.add(new S3Bucket(node.getTextContent()));
            }
        } else {
            System.out.println("Unable to access to your S3 buckets : "
                    + response.getStatus());
View Full Code Here

            suffix = "&";
        }

        // Make the request and parse the document.
        final Response response = authorizedGet(uri.toString());
        final DomRepresentation document = new DomRepresentation(response
                .getEntity());

        // Update the truncated flag
        this.truncated = document.getNodes("//IsTruncated").get(0)
                .getTextContent().equals("true");

        // Browse the list of object keys
        for (final Node node : document.getNodes("//Contents/Key")) {
            result.add(new S3Object(this, node.getTextContent()));
        }

        return result;
    }
View Full Code Here

    }

    @Get("xml")
    public Representation toXml() {
        try {
            DomRepresentation representation = new DomRepresentation(
                    MediaType.TEXT_XML);
            // Generate a DOM document representing the item.
            Document d = representation.getDocument();

            Element eltItem = d.createElement("item");
            d.appendChild(eltItem);
            Element eltName = d.createElement("name");
            eltName.appendChild(d.createTextNode(item.getName()));
View Full Code Here

                "/org/restlet/Component.xsd");
        assertNotNull("Component.xsd stream MUST NOT be null", is);
        Representation schemaRepresentation = new InputRepresentation(is,
                MediaType.APPLICATION_W3C_SCHEMA);

        DomRepresentation configRepresentation = new DomRepresentation(
                new StringRepresentation(XML_WITH_XMLNS));

        try {
            configRepresentation.validate(schemaRepresentation);
            assertTrue(true);
        } catch (Exception x) {
            x.printStackTrace(System.err);
            fail(x.getLocalizedMessage());
        }
View Full Code Here

     * @param textContent
     *            The content of that element as text.
     */
    public void setTextContent(String textContent) {
        try {
            Document doc = new DomRepresentation(MediaType.TEXT_XML)
                    .getDocument();
            this.mixedContent = doc.createTextNode(textContent);
        } catch (IOException e) {
        }
    }
View Full Code Here

        if (MediaType.APPLICATION_ALL_XML.isCompatible(representation
                .getMediaType())
                || MediaType.TEXT_XML.isCompatible(representation
                        .getMediaType())) {
            DomRepresentation xmlRep = new DomRepresentation(representation);
            Node node = xmlRep.getNode("//" + tagName);


            if (node != null) {
                result = node.getTextContent();
            }
View Full Code Here

            this.currentResources = null;
            this.currentResourceType = null;
            this.currentResponse = null;

            try {
                this.mixedContentDocument = new DomRepresentation(
                        MediaType.TEXT_XML).getDocument();
            } catch (IOException e) {
            }

            this.currentMixedContentCDataSection = null;
View Full Code Here

TOP

Related Classes of org.restlet.ext.xml.DomRepresentation

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.