Example usage for org.xml.sax.helpers AttributesImpl AttributesImpl

List of usage examples for org.xml.sax.helpers AttributesImpl AttributesImpl

Introduction

In this page you can find the example usage for org.xml.sax.helpers AttributesImpl AttributesImpl.

Prototype

public AttributesImpl() 

Source Link

Document

Construct a new, empty AttributesImpl object.

Usage

From source file:uk.ac.ebi.arrayexpress.utils.saxon.FlatFileXMLReader.java

private void outputRow(ContentHandler ch, boolean isHeader, String seqValue, String[] rowData)
        throws SAXException {
    String rowElement = isHeader ? "header" : "row";

    AttributesImpl rowAttrs = new AttributesImpl();
    if (null != seqValue) {
        rowAttrs.addAttribute(EMPTY_NAMESPACE, "seq", "seq", CDATA_TYPE, seqValue);
    }/*from   ww w  .java  2 s . c o  m*/
    rowAttrs.addAttribute(EMPTY_NAMESPACE, "cols", "cols", CDATA_TYPE, String.valueOf(rowData.length));
    ch.startElement(EMPTY_NAMESPACE, rowElement, rowElement, rowAttrs);

    for (String col : rowData) {
        if (isHeader) {
            col = StringUtils.trimToEmpty(col);
        }
        ch.startElement(EMPTY_NAMESPACE, "col", "col", EMPTY_ATTR);
        ch.characters(col.toCharArray(), 0, col.length());
        ch.endElement(EMPTY_NAMESPACE, "col", "col");
    }
    ch.endElement(EMPTY_NAMESPACE, rowElement, rowElement);
}