Example usage for javax.xml.stream XMLStreamWriter writeAttribute

List of usage examples for javax.xml.stream XMLStreamWriter writeAttribute

Introduction

In this page you can find the example usage for javax.xml.stream XMLStreamWriter writeAttribute.

Prototype

public void writeAttribute(String localName, String value) throws XMLStreamException;

Source Link

Document

Writes an attribute to the output stream without a prefix.

Usage

From source file:org.tolven.app.bean.DataExtractBean.java

protected void addXMLColumnHeadings(DataQueryResults dq, XMLStreamWriter xmlStreamWriter)
        throws XMLStreamException {
    xmlStreamWriter.writeStartElement("columns");
    for (DataField field : dq.getSelectedFields()) {
        xmlStreamWriter.writeStartElement("col");
        xmlStreamWriter.writeAttribute("name", xmlName(field));
        xmlStreamWriter.writeEndElement();
    }/*from w  w  w .  j  a v a 2s .  co  m*/
    xmlStreamWriter.writeEndElement();
}

From source file:org.tolven.app.bean.DataExtractBean.java

protected void writeXMLColumn(XMLStreamWriter xmlStreamWriter, DataField field, Object obj)
        throws XMLStreamException {
    if (obj != null) {
        String value;// w w w  .j av a 2s.c  o  m
        xmlStreamWriter.writeStartElement(xmlName(field));
        if (field.getExternal().equalsIgnoreCase("placeholderIds")) {
            //fill me in with a for loop over the placeholder ids
            Object[] plist = (Object[]) obj;
            for (Object pobj : plist) {
                String[] pentry = pobj.toString().split(",");
                String proot = pentry[0].toString();
                String pext = pentry[1].toString();
                xmlStreamWriter.writeStartElement("id");
                xmlStreamWriter.writeAttribute("root", StringEscapeUtils.escapeXml(proot));
                xmlStreamWriter.writeAttribute("extension", StringEscapeUtils.escapeXml(pext));
                xmlStreamWriter.writeEndElement();
            }
        } else {
            value = obj.toString();
            String df = field.getDisplayFunction();
            if (df != null && "age".equalsIgnoreCase(df)) {
                value = ELFunctions.age((Date) obj, TolvenRequest.getInstance().getAccountUser());
            }
            xmlStreamWriter.writeCharacters(StringEscapeUtils.escapeXml(value));
        }
        xmlStreamWriter.writeEndElement();
    }
}

From source file:org.tolven.assembler.ear.EARAssembler.java

protected void addConnectorModule(String rarFilename, XMLStreamWriter writer) throws XMLStreamException {
    writer.writeStartElement("xsl:if");
    writer.writeAttribute("test", "count(module/connector[text() = '" + rarFilename + "']) = 0");
    writer.writeCharacters("\n");
    writer.writeStartElement("module");
    writer.writeCharacters("\n");
    writer.writeStartElement("connector");
    writer.writeCharacters(rarFilename);
    writer.writeEndElement();/*from   www .ja  v  a  2 s.com*/
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
}

From source file:org.tolven.assembler.ear.EARAssembler.java

protected void addConnectorModuleTemplates(PluginDescriptor pd, File localDestDir, XMLStreamWriter writer)
        throws XMLStreamException, IOException {
    writer.writeStartElement("xsl:template");
    writer.writeAttribute("name", "addConnectorModules");
    writer.writeCharacters("\n");
    assembleConnectorModuleProducts(pd, writer);
    assembleConnectorModuleProductAdaptors(pd, localDestDir, writer);
    writer.writeEndElement();//from  w w  w. j  a  v  a  2 s .co  m
    writer.writeCharacters("\n");
}

From source file:org.tolven.assembler.ear.EARAssembler.java

protected void addEJBModuleTemplates(PluginDescriptor pd, File localDestDir, XMLStreamWriter writer)
        throws XMLStreamException, IOException {
    writer.writeStartElement("xsl:template");
    writer.writeAttribute("name", "addEJBModules");
    writer.writeCharacters("\n");
    assembleEJBModuleAdaptors(pd, writer);
    assembleEJBModuleProducts(pd, localDestDir, writer);
    assembleEJBModuleProductAdaptors(pd, localDestDir, writer);
    writer.writeEndElement();/*ww  w  .jav a  2 s  . c  o  m*/
    writer.writeCharacters("\n");
}

From source file:org.tolven.assembler.ear.EARAssembler.java

protected void addEJBModuleXMLEntry(String jarFilename, XMLStreamWriter writer) throws XMLStreamException {
    writer.writeStartElement("xsl:if");
    writer.writeAttribute("test", "count(module/ejb[text() = '" + jarFilename + "']) = 0");
    writer.writeCharacters("\n");
    writer.writeStartElement("module");
    writer.writeCharacters("\n");
    writer.writeStartElement("ejb");
    writer.writeCharacters(jarFilename);
    writer.writeEndElement();// w w  w. jav a2  s .  c  o  m
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
}

From source file:org.tolven.assembler.ear.EARAssembler.java

protected void addMainTemplate(XMLStreamWriter writer) throws XMLStreamException {
    writer.writeStartElement("xsl:template");
    writer.writeAttribute("match", "/ | * | @* | text() | comment()");
    writer.writeCharacters("\n");
    writer.writeStartElement("xsl:copy");
    writer.writeAttribute("select", ".");
    writer.writeCharacters("\n");
    writer.writeStartElement("xsl:apply-templates");
    writer.writeAttribute("select", "* | @* | text() | comment()");
    writer.writeEndElement();//w w  w. j  a  v a  2s.  co m
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
}

From source file:org.tolven.assembler.ear.EARAssembler.java

protected void addRootConnectorModuleSelects(XMLStreamWriter writer) throws XMLStreamException {
    writer.writeStartElement("xsl:for-each");
    writer.writeAttribute("select", "tp:module/tp:connector");
    writer.writeCharacters("\n");
    writer.writeStartElement("xsl:copy-of");
    writer.writeAttribute("select", ".");
    writer.writeCharacters("\n");
    writer.writeStartElement("xsl:apply-templates");
    writer.writeAttribute("select", "* | @* | text() | comment()");
    writer.writeEndElement();/*from   w ww .  j av a 2s . com*/
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
    writer.writeStartElement("xsl:call-template");
    writer.writeAttribute("name", "addConnectorModules");
    writer.writeEndElement();
    writer.writeCharacters("\n");
}

From source file:org.tolven.assembler.ear.EARAssembler.java

protected void addRootDisplayName(XMLStreamWriter writer) throws XMLStreamException {
    writer.writeStartElement("xsl:if");
    writer.writeAttribute("test", "count(display-name) = 0");
    writer.writeStartElement("xsl:element");
    writer.writeAttribute("name", "display-name");
    writer.writeCharacters("Tolven Application");
    writer.writeEndElement();/*w  w w . j a va2  s .  co  m*/
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
}

From source file:org.tolven.assembler.ear.EARAssembler.java

protected void addRootEJBModuleSelects(XMLStreamWriter writer) throws XMLStreamException {
    writer.writeStartElement("xsl:for-each");
    writer.writeAttribute("select", "tp:module/tp:ejb");
    writer.writeCharacters("\n");
    writer.writeStartElement("xsl:copy-of");
    writer.writeAttribute("select", ".");
    writer.writeCharacters("\n");
    writer.writeStartElement("xsl:apply-templates");
    writer.writeAttribute("select", "* | @* | text() | comment()");
    writer.writeEndElement();/*from   ww w.  j  av  a  2s .  c om*/
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
    writer.writeStartElement("xsl:call-template");
    writer.writeAttribute("name", "addEJBModules");
    writer.writeEndElement();
    writer.writeCharacters("\n");
}