groovy.util.XmlParser Java Examples

The following examples show how to use groovy.util.XmlParser. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XmlTransformer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Node asNode() {
    if (node == null) {
        try {
            node = new XmlParser().parseText(toString());
        } catch (Exception e) {
            throw UncheckedException.throwAsUncheckedException(e);
        }
        builder = null;
        element = null;
    }
    return node;
}
 
Example #2
Source File: XmlTransformer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Node asNode() {
    if (node == null) {
        try {
            node = new XmlParser().parseText(toString());
        } catch (Exception e) {
            throw UncheckedException.throwAsUncheckedException(e);
        }
        builder = null;
        element = null;
    }
    return node;
}
 
Example #3
Source File: TransformActivity.java    From mdw with Apache License 2.0 5 votes vote down vote up
private Object getGPathParamValue(String varName, String varType) throws ActivityException {
    Object value = getValue(varName);
    VariableTranslator translator = getPackage().getTranslator(varType);
    if (translator instanceof DocumentReferenceTranslator) {
        try {
            DocumentReferenceTranslator docRefTranslator = (DocumentReferenceTranslator) translator;
            outputDocumentWriter = new StringWriter();
            if (isOutputDocument(varName)) {
                if (value == null) {
                    MarkupBuilder builder = new MarkupBuilder(outputDocumentWriter);
                    builder.setDoubleQuotes(true);
                    value = builder;
                }
                else {
                    value = new XmlParser().parseText(docRefTranslator.toString(value, varType));
                }
            }
            else {
                value = new XmlSlurper().parseText(docRefTranslator.toString(value, varType));
            }
        }
        catch (Exception ex) {
            getLogger().error(ex.getMessage(), ex);
            throw new ActivityException(ex.getMessage(), ex);
        }
    }

    return value;
}
 
Example #4
Source File: GroovyNodeTranslator.java    From mdw with Apache License 2.0 5 votes vote down vote up
public Object toObject(String str, String type) throws TranslationException {
    try {
        return new XmlParser().parseText(str);
    } catch (Exception e) {
        throw new TranslationException(e.getMessage(), e);
    }
}
 
Example #5
Source File: XmlTransformer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Node asNode() {
    if (node == null) {
        try {
            node = new XmlParser().parseText(toString());
        } catch (Exception e) {
            throw UncheckedException.throwAsUncheckedException(e);
        }
        builder = null;
        element = null;
    }
    return node;
}
 
Example #6
Source File: XmlTransformer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public Node asNode() {
    if (node == null) {
        try {
            node = new XmlParser().parseText(toString());
        } catch (Exception e) {
            throw UncheckedException.throwAsUncheckedException(e);
        }
        builder = null;
        element = null;
    }
    return node;
}
 
Example #7
Source File: ScoverageFunctionalTest.java    From gradle-scoverage with Apache License 2.0 5 votes vote down vote up
protected ScoverageFunctionalTest(String projectName) {
    setProjectName(projectName);
    try {
        this.parser = new XmlParser();
        parser.setFeature("http://apache.org/xml/features/disallow-doctype-decl", false);
        parser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}