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

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

Introduction

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

Prototype

public static String escapeAttributeXML(String in) 

Source Link

Document

Returns a String in which some 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());
    }//w w  w  . j a v  a 2  s . c o m
    sb.append("<").append(XMLUtils.escapeXML("/sentence")).append(">");
    return sb.toString();
}