Example usage for edu.stanford.nlp.util XMLUtils escapeXML

List of usage examples for edu.stanford.nlp.util XMLUtils escapeXML

Introduction

In this page you can find the example usage for edu.stanford.nlp.util XMLUtils escapeXML.

Prototype

public static String escapeXML(String in) 

Source Link

Document

Returns a String in which all the XML special characters have been escaped.

Usage

From source file:final_dissertation.POStag.java

public static String getXMLWords(ArrayList<TaggedWord> taggedSentence, int sentNum) {
    StringBuilder sb = new StringBuilder();
    sb.append(System.lineSeparator());
    sb.append("<").append(XMLUtils.escapeTextAroundXMLTags("sentence")).append(" id=\"")
            .append(XMLUtils.escapeAttributeXML("" + sentNum)).append("\">");
    sb.append(System.lineSeparator());
    int sz = ((List) taggedSentence).size();
    for (int i = 0; i < sz; i++) {
        String word = ((HasWord) ((List) taggedSentence).get(i)).word();
        String tag = ((TaggedWord) ((List) taggedSentence).get(i)).tag();
        sb.append("<").append(XMLUtils.escapeTextAroundXMLTags("word")).append(" wid=\"")
                .append(XMLUtils.escapeAttributeXML("" + i)).append("\"").append(" pos=\"")
                .append(XMLUtils.escapeAttributeXML(tag)).append("\">").append(XMLUtils.escapeElementXML(word))
                .append("<").append(XMLUtils.escapeTextAroundXMLTags("/word")).append(">")
                .append(System.lineSeparator());
    }//from  w w  w . j  av  a  2 s  . com
    sb.append("<").append(XMLUtils.escapeXML("/sentence")).append(">");
    return sb.toString();
}