All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.imsweb.validation.internal.xml.TestsXmlDriver Maven / Gradle / Ivy

Go to download

This framework allows edits to be defined in Groovy and to be executed on various data types.

There is a newer version: 021-11
Show newest version
/*
 * Copyright (C) 2021 Information Management Services, Inc.
 */
package com.imsweb.validation.internal.xml;

import java.io.Writer;

import org.xmlpull.v1.XmlPullParser;

import com.thoughtworks.xstream.core.util.QuickWriter;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
import com.thoughtworks.xstream.io.xml.AbstractXppDriver;
import com.thoughtworks.xstream.io.xml.PrettyPrintWriter;
import com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder;

import io.github.xstream.mxparser.MXParser;

public class TestsXmlDriver extends AbstractXppDriver {

    /**
     * Construct.
     */
    public TestsXmlDriver() {
        super(new XmlFriendlyNameCoder());
    }

    @Override
    protected XmlPullParser createParser() {
        return new MXParser();
    }

    @Override
    public HierarchicalStreamWriter createWriter(Writer out) {
        return new PrettyPrintWriter(out, "    ") {
            boolean _cdata = false;

            @Override
            public void startNode(String name) {
                super.startNode(name);
                _cdata = "script".equals(name);
            }

            @Override
            protected void writeText(QuickWriter writer, String text) {
                if (_cdata) {
                    writer.write("");
                }
                else
                    super.writeText(writer, text);
            }
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy