Example usage for com.google.gwt.xml.client Document createCDATASection

List of usage examples for com.google.gwt.xml.client Document createCDATASection

Introduction

In this page you can find the example usage for com.google.gwt.xml.client Document createCDATASection.

Prototype

CDATASection createCDATASection(String data);

Source Link

Document

This method creates a new CDATASection.

Usage

From source file:org.openxdata.designer.client.xforms.OpenXdataFormBuilder.java

public static String build(FormDef formDef, HashMap<String, String> localeText) {

    Document doc = XMLParser.createDocument();
    doc.appendChild(doc.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""));

    Element openXdataFormNode = doc.createElement("PurcForm");
    doc.appendChild(openXdataFormNode);//w w w  . j a  v a2s  .c o m

    Element xformNode = doc.createElement("Xform");
    Element node = (Element) formDef.getDoc().getDocumentElement().cloneNode(true);
    doc.importNode(node, true);
    xformNode.appendChild(node);
    openXdataFormNode.appendChild(xformNode);

    String xml = formDef.getLayoutXml();
    if (xml != null && xml.trim().length() > 0) {
        node = (Element) XmlUtil.getDocument(xml).getDocumentElement().cloneNode(true);
        doc.importNode(node, true);
        Element layoutNode = doc.createElement("Layout");
        layoutNode.appendChild(node);
        openXdataFormNode.appendChild(layoutNode);
    }

    String src = formDef.getJavaScriptSource();
    if (src != null && src.trim().length() > 0) {
        Element javaScriptNode = doc.createElement("JavaScript");
        javaScriptNode.appendChild(doc.createCDATASection(src));
        openXdataFormNode.appendChild(javaScriptNode);
    }

    openXdataFormNode.appendChild(getLanguageNode(doc, localeText));

    return XmlUtil.fromDoc2String(doc);
}