Example usage for org.dom4j DocumentHelper createCDATA

List of usage examples for org.dom4j DocumentHelper createCDATA

Introduction

In this page you can find the example usage for org.dom4j DocumentHelper createCDATA.

Prototype

public static CDATA createCDATA(String text) 

Source Link

Usage

From source file:mesquite.chromaseq.lib.SequenceProfile.java

License:Open Source License

public String getXML() {
    Element mesquiteElement = DocumentHelper.createElement("mesquite");
    Document doc = DocumentHelper.createDocument(mesquiteElement);
    Element sequenceProfileElement = DocumentHelper.createElement("sequenceProfile");
    mesquiteElement.add(sequenceProfileElement);
    XMLUtil.addFilledElement(sequenceProfileElement, "version", "1");
    Element boundedByTokensElement = DocumentHelper.createElement("boundedByTokens");
    sequenceProfileElement.add(boundedByTokensElement);
    XMLUtil.addFilledElement(boundedByTokensElement, "name", name);
    XMLUtil.addFilledElement(boundedByTokensElement, "description", DocumentHelper.createCDATA(description));
    XMLUtil.addFilledElement(boundedByTokensElement, "location", DocumentHelper.createCDATA(location));
    XMLUtil.addFilledElement(boundedByTokensElement, "moltype", DocumentHelper.createCDATA(moltype));
    XMLUtil.addFilledElement(boundedByTokensElement, "productName", DocumentHelper.createCDATA(productName));
    XMLUtil.addFilledElement(boundedByTokensElement, "seqIDSuffix", DocumentHelper.createCDATA(seqIDSuffix));
    XMLUtil.addFilledElement(boundedByTokensElement, "gcode", DocumentHelper.createCDATA("" + gcode));
    XMLUtil.addFilledElement(boundedByTokensElement, "note", DocumentHelper.createCDATA("" + note));
    //      XMLUtil.addFilledElement(boundedByTokensElement, "CDS",DocumentHelper.createCDATA(MesquiteBoolean.toTrueFalseString(CDS)));
    return XMLUtil.getDocumentAsXMLString(doc);
}

From source file:mesquite.chromaseq.SampleAndPrimerFileNameParser.ChromFileNameParsing.java

License:Open Source License

public String getXML() {
    Element mesquiteElement = DocumentHelper.createElement("mesquite");
    Document doc = DocumentHelper.createDocument(mesquiteElement);
    Element nameRules = DocumentHelper.createElement("chromFileNameParsingRules");
    mesquiteElement.add(nameRules);/*from   ww w.jav a  2  s .com*/
    XMLUtil.addFilledElement(nameRules, "version", "1");
    Element boundedByTokensElement = DocumentHelper.createElement("boundedByTokens");
    nameRules.add(boundedByTokensElement);
    XMLUtil.addFilledElement(boundedByTokensElement, "name", name);
    XMLUtil.addFilledElement(boundedByTokensElement, "sampleCodeFirst",
            MesquiteBoolean.toTrueFalseString(sampleCodeFirst));
    XMLUtil.addFilledElement(boundedByTokensElement, "dnaCodeStartToken",
            DocumentHelper.createCDATA(dnaCodeStartToken));
    XMLUtil.addFilledElement(boundedByTokensElement, "dnaCodeEndToken",
            DocumentHelper.createCDATA(dnaCodeEndToken));
    XMLUtil.addFilledElement(boundedByTokensElement, "dnaCodeSuffixToken",
            DocumentHelper.createCDATA(dnaCodeSuffixToken));
    XMLUtil.addFilledElement(boundedByTokensElement, "dnaCodeRemovalToken",
            DocumentHelper.createCDATA(dnaCodeRemovalToken));
    XMLUtil.addFilledElement(boundedByTokensElement, "primerStartToken",
            DocumentHelper.createCDATA(primerStartToken));
    XMLUtil.addFilledElement(boundedByTokensElement, "primerEndToken",
            DocumentHelper.createCDATA(primerEndToken));
    return XMLUtil.getDocumentAsXMLString(doc);
}

From source file:mesquite.lib.MesquiteXMLPreferencesModule.java

License:Open Source License

/**
 * Ideally this should not be static but since we don't always have control over the superclass,
 * make it available for classes that might otherwise not be able to use it due to inheritance
 * constraints//  ww w. j a  v  a2 s.co m
 * @param provider
 * @param versionInt
 * @return
 */
public static String preparePreferencesForXML(PropertyNamesProvider provider, int versionInt) {
    String[] propertyNames = provider.getPreferencePropertyNames();
    Element rootElement = DocumentHelper.createElement("mesquite");
    Document preferencesDoc = DocumentHelper.createDocument(rootElement);
    preferencesDoc.setRootElement(rootElement);
    Element classElement = DocumentHelper.createElement(getShortClassName(provider.getClass()));
    rootElement.add(classElement);
    Element versionElement = DocumentHelper.createElement(VERSION);
    versionElement.setText("" + versionInt);
    classElement.add(versionElement);
    for (int i = 0; i < propertyNames.length; i++) {
        String currentPropertyName = propertyNames[i];
        try {
            Object prefsContent = PropertyUtils.read(provider, currentPropertyName);
            if (prefsContent != null) {
                Element nextPrefsElement = DocumentHelper.createElement(PREFERENCE);
                nextPrefsElement.addAttribute(KEY, currentPropertyName);
                nextPrefsElement.add(DocumentHelper.createCDATA(prefsContent.toString()));
                classElement.add(nextPrefsElement);
            }
        } catch (Exception e) {
            MesquiteMessage.warnProgrammer("Could not read property value " + currentPropertyName
                    + " for writing xml preferences on module: " + provider);
        }
        //nextPrefsElement.addContent(new CDATA())
    }
    return XMLUtil.getDocumentAsXMLString(preferencesDoc);
}

From source file:mesquite.lib.PhoneHomeUtil.java

License:Open Source License

public static void writePhoneRecords(String path, ListableVector phoneRecords) {
    if (StringUtil.blank(path))
        return;//from w  ww . ja v  a 2  s .com
    Element mesquiteElement = DocumentHelper.createElement("mesquite");
    Document doc = DocumentHelper.createDocument(mesquiteElement);
    Element phoneRecordElement = DocumentHelper.createElement("phoneRecords");
    mesquiteElement.add(phoneRecordElement);
    Element versionElement = DocumentHelper.createElement("version");
    versionElement.addText("1");
    phoneRecordElement.add(versionElement);

    for (int i = 0; i < phoneRecords.size(); i++) {
        Element recordElement = DocumentHelper.createElement("record");
        phoneRecordElement.add(recordElement);
        PhoneHomeRecord phoneRecord = (PhoneHomeRecord) phoneRecords.elementAt(i);
        Element element = DocumentHelper.createElement("module");
        element.add(DocumentHelper.createCDATA(phoneRecord.getModuleName()));
        recordElement.add(element);
        MesquiteModuleInfo mmi = MesquiteTrunk.mesquiteModulesInfoVector.findModule(MesquiteModule.class,
                phoneRecord.getModuleName());
        XMLUtil.addFilledElement(recordElement, "lastVersionUsed",
                MesquiteInteger.toString(phoneRecord.getLastVersionUsed()));
        XMLUtil.addFilledElement(recordElement, "lastNotice",
                MesquiteInteger.toString(phoneRecord.getLastNotice()));
        XMLUtil.addFilledElement(recordElement, "lastNoticeForMyVersion",
                MesquiteInteger.toString(phoneRecord.getLastNoticeForMyVersion()));
        XMLUtil.addFilledElement(recordElement, "lastVersionNoticed",
                MesquiteInteger.toString(phoneRecord.getLastVersionNoticed()));
        XMLUtil.addFilledElement(recordElement, "lastNewerVersionReported",
                MesquiteInteger.toString(phoneRecord.getLastNewerVersionReported()));
    }
    String xml = XMLUtil.getDocumentAsXMLString(doc);
    if (!StringUtil.blank(xml))
        MesquiteFile.putFileContents(path, xml, true);

}

From source file:org.dentaku.gentaku.tools.cgen.xmi.XMIGenTask.java

License:Apache License

private void buildDocument(Element model, Document schemaDoc, Document mappingDoc, LocalDefaultElement rootNode,
        Element groupTagdef, Element gengenStereotype, Element xsdTagdef, Element mappingTagdef) {
    Element modelPackage;/*from w  ww  .ja v  a  2s.c  o  m*/

    String packageName = mappingDoc.getRootElement().attributeValue("tagNameBase");
    // add the package for this package
    modelPackage = createPackageHierarchy(packageName, model);

    // create tagdefs into gengen
    Element emptyUMLElement = createEmptyUMLElement(modelPackage, "ModelElement.taggedValue");
    createUMLTaggedValue(emptyUMLElement, xsdTagdef, DocumentHelper.createCDATA(schemaDoc.asXML()));

    // add one to the package we are creating
    modelPackage.addAttribute("stereotype", gengenStereotype.attributeValue("xmi.id"));

    createUMLTaggedValue(emptyUMLElement, mappingTagdef, DocumentHelper.createCDATA(mappingDoc.asXML()));

    Element scratchPackage = createOwnedElement(modelPackage);

    Element enumeration = createIdentifiedEmptyElement(scratchPackage, "Enumeration")
            .addAttribute("name", packageName).addElement("UML:Enumeration.literal", "omg.org/UML/1.4");

    // this is the real work
    String groupPrefix = packageName.substring(packageName.lastIndexOf(".") + 1);
    processNodeTags(rootNode, enumeration, scratchPackage, null, rootNode, groupTagdef, new String[0],
            schemaDoc, groupPrefix);

    // finally, create the stereotypes that are defined in the mapping doc
    generateStereotypes(mappingDoc, scratchPackage, schemaDoc, schemaDoc);
}