Example usage for org.jdom2.output XMLOutputter outputString

List of usage examples for org.jdom2.output XMLOutputter outputString

Introduction

In this page you can find the example usage for org.jdom2.output XMLOutputter outputString.

Prototype

public final String outputString(EntityRef entity) 

Source Link

Document

Return a string representing an EntityRef .

Usage

From source file:org.yawlfoundation.yawl.util.JDOMUtil.java

License:Open Source License

/****************************************************************************/

public static String documentToStringDump(Document doc) {
    if (doc == null)
        return null;
    XMLOutputter out = new XMLOutputter(Format.getCompactFormat());
    return out.outputString(doc);
}

From source file:org.yawlfoundation.yawl.util.JDOMUtil.java

License:Open Source License

/****************************************************************************/

public static String elementToString(Element e) {
    if (e == null)
        return null;
    XMLOutputter out = new XMLOutputter(Format.getPrettyFormat());
    return out.outputString(e);
}

From source file:org.yawlfoundation.yawl.util.JDOMUtil.java

License:Open Source License

/****************************************************************************/

public static String elementToStringDump(Element e) {
    if (e == null)
        return null;
    XMLOutputter out = new XMLOutputter(Format.getCompactFormat());
    return out.outputString(e);
}

From source file:pl.edu.pwr.iiar.zak.thermalKit.util.ReadDesign.java

License:Open Source License

public void showDesign(String filename) throws JDOMException, IOException {
    try {/*from  w ww. j ava 2s .  c om*/
        System.out.println("Converting NCD file to XDL...");
        FileConverter.convertNCD2XDL(filename);
    } catch (NullPointerException e) {
        System.out.println("Please indicate correct ncd file!");
        System.exit(0);
    }
    Design design = new Design();
    design.loadXDLFile(filename.substring(0, filename.length() - 3) + "xdl");
    Device device = design.getDevice();

    Document writer = new Document();
    Element rootElement = new Element("device");
    writer.addContent(rootElement);
    rootElement.setAttribute(new Attribute("version", "0.2"));
    rootElement.setAttribute(new Attribute("name", device.getPartName()));

    Element size = new Element("size");
    rootElement.addContent(size);
    size.setAttribute(new Attribute("cols", String.format("%d", device.getColumns())));
    size.setAttribute(new Attribute("rows", String.format("%d", device.getRows())));

    Element clbsize = new Element("clbsize");
    rootElement.addContent(clbsize);
    clbsize.setAttribute(new Attribute("width", "0.00025"));
    clbsize.setAttribute(new Attribute("height", "0.0002"));

    int old_z = -1;
    int k = 0;
    String progress_bar = "|/-\\";
    for (int row = 0; row < device.getColumns(); row++) {
        if (print) {
            System.out.format("%d\t", row + 1);
        }
        for (int col = 0; col < device.getRows(); col++) {
            System.out.println(String.format("Col: %d, Row: %d", col, row));
            System.out.println(design.getDevice().getTile(col, row).getName());
            if (design.getDevice().getTile(col, row).getName().contains("CLB")) {
                try {
                    boolean used = false;
                    for (PrimitiveSite ps : design.getDevice().getTile(col, row).getPrimitiveSites()) {
                        if (design.isPrimitiveSiteUsed(ps)) {
                            used = true;
                        }
                    }
                    if (used) {
                        if (print) {
                            System.out.print("@");
                        }
                        rootElement.addContent(addElement(row, col, "unit"));
                    } else {
                        if (print) {
                            System.out.print("*");
                        }
                    }
                    k++;
                } catch (Exception e) {
                    if (print) {
                        System.out.print("#");
                    }
                    rootElement.addContent(addElement(row, col, "obstacle"));
                }
            } else {
                rootElement.addContent(addElement(row, col, "obstacle"));
                if (print) {
                    System.out.print("#");
                }
            }
        }
        if (print) {
            System.out.println();
        } else {
            int z = (int) ((row / 177.0) * 100);
            if (old_z != z) {
                System.out.write(progressBar(z, 50).getBytes());
                old_z = z;
            }
        }
    }
    System.out.format("\nNumber of CLB tiles %d\n", k);
    System.out.format("Number of columns %d; Number of rows %d\n", design.getDevice().getColumns(),
            design.getDevice().getRows());
    System.out.println("Creating XML file with device floorplan...");
    XMLOutputter xml = new XMLOutputter();
    xml.setFormat(Format.getPrettyFormat());

    String path = "floorplan.xml";

    if (!print) {
        PrintWriter xmlWriter = new PrintWriter(path, "UTF-8");
        xmlWriter.print(xml.outputString(writer));
        xmlWriter.close();
        System.out.println("FPGA description saved in floorplan.xml!");
    }
}

From source file:pt.ist.socialsoftware.edition.export.ExpertEditionTEIExport.java

License:Creative Commons License

public String getXMLResult() {
    XMLOutputter xml = new XMLOutputter();
    // we want to format the xml. This is used only for demonstration.
    // pretty formatting adds extra spaces and is generally not required.
    xml.setFormat(Format.getPrettyFormat());
    return updateTeiHeader(xml.outputString(this.jdomDoc));
}

From source file:pt.ist.socialsoftware.edition.visitors.TEIGenerator.java

License:Creative Commons License

public String getXMLResult() {
    XMLOutputter xml = new XMLOutputter();
    // we want to format the xml. This is used only for demonstration.
    // pretty formatting adds extra spaces and is generally not required.
    xml.setFormat(Format.getPrettyFormat());
    return updateTeiHeader(xml.outputString(jdomDoc));

}

From source file:pt.ua.dicoogle.webservices.RestTagsResource.java

License:Open Source License

@Get
public Representation representXML() {
    StringRepresentation sr;/* w  w w  . j  a  v a2 s .c  o m*/

    HashMap<String, Integer> tagList = DictionaryAccess.getInstance().getTagList();

    ArrayList<String> list = new ArrayList<String>();
    Element tags = new Element("tags");
    for (String tag : tagList.keySet()) {
        int value = tagList.get(tag);

        Element e = new Element("tag");
        e.setAttribute("id", Integer.toString(value));
        e.setAttribute("name", tag);
        tags.addContent(e);
    }

    tags.setAttribute("count", Integer.toString(tags.getChildren().size()));
    Document xmlDoc = new Document(tags);

    XMLOutputter out = new XMLOutputter(Format.getCompactFormat());
    String str = out.outputString(xmlDoc);

    StringRepresentation rep = new StringRepresentation(str, MediaType.APPLICATION_XML);

    return rep;
}

From source file:qtiscoringengine.QTIUtility.java

License:Open Source License

static String nodeToString(Element node) {
    if (node == null)
        return "";
    XMLOutputter out = new XMLOutputter(Format.getPrettyFormat());
    return out.outputString(node);
}

From source file:Report.Report.java

License:Open Source License

public void printOut(PrintStream pw) {
    unlazy();//w w w  .  ja v a2s .co m
    XMLOutputter xml = new XMLOutputter();
    xml.setFormat(Format.getPrettyFormat());
    pw.println(xml.outputString(jdomDoc));

}

From source file:rezeptsuperpos.GenericArchive.java

License:Open Source License

@Override
public String toString() {
    Format format = Format.getPrettyFormat();
    XMLOutputter xmlOutputter = new XMLOutputter();
    xmlOutputter.setFormat(format);/*from  w w  w .  jav a 2 s.c  om*/
    return xmlOutputter.outputString(document);
}