Example usage for javax.xml.stream XMLStreamWriter writeCharacters

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

Introduction

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

Prototype

public void writeCharacters(String text) throws XMLStreamException;

Source Link

Document

Write text to the output

Usage

From source file:org.tolven.assembler.webxml.WebXMLAssembler.java

protected void addRootWebSecurityConstraintSelects(XMLStreamWriter xmlStreamWriter) throws XMLStreamException {
    xmlStreamWriter.writeStartElement("xsl:for-each");
    xmlStreamWriter.writeAttribute("select", "tp:security-constraint");
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("xsl:copy-of");
    xmlStreamWriter.writeAttribute("select", ".");
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("xsl:apply-templates");
    xmlStreamWriter.writeAttribute("select", "* | @* | text() | comment()");
    xmlStreamWriter.writeEndElement();//  w w  w . j a  va 2 s.c  om
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("xsl:call-template");
    xmlStreamWriter.writeAttribute("name", "addWebSecurityConstraints");
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
}

From source file:org.tolven.assembler.webxml.WebXMLAssembler.java

protected void addRootWelcomeFileListSelects(XMLStreamWriter xmlStreamWriter) throws XMLStreamException {
    xmlStreamWriter.writeStartElement("xsl:for-each");
    xmlStreamWriter.writeAttribute("select", "tp:welcome-file-list");
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("xsl:copy-of");
    xmlStreamWriter.writeAttribute("select", ".");
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("xsl:apply-templates");
    xmlStreamWriter.writeAttribute("select", "* | @* | text() | comment()");
    xmlStreamWriter.writeEndElement();//w ww.j  a v  a  2  s.c om
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("xsl:call-template");
    xmlStreamWriter.writeAttribute("name", "addWelcomeFileLists");
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
}

From source file:org.tolven.assembler.webxml.WebXMLAssembler.java

protected void addSecurityRole(String roleName, XMLStreamWriter xmlStreamWriter) throws XMLStreamException {
    xmlStreamWriter.writeStartElement("xsl:if");
    xmlStreamWriter.writeAttribute("test", "count(tp:security-role[tp:role-name = '" + roleName + "']) = 0");
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("security-role");
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("role-name");
    xmlStreamWriter.writeCharacters(roleName);
    xmlStreamWriter.writeEndElement();/*from www.  j  a  v  a  2  s . c o  m*/
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
}

From source file:org.tolven.assembler.webxml.WebXMLAssembler.java

protected void addSecurityRoleTemplates(PluginDescriptor pd, XMLStreamWriter xmlStreamWriter)
        throws XMLStreamException {
    xmlStreamWriter.writeStartElement("xsl:template");
    xmlStreamWriter.writeAttribute("name", "addSecurityRoles");
    xmlStreamWriter.writeCharacters("\n");
    for (Extension exn : getExtensions(pd, "security-role")) {
        addSecurityRole(exn.getParameter("role-name").valueAsString(), xmlStreamWriter);
    }//from w ww .j a  v a  2s  .c o m
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
}

From source file:org.tolven.assembler.webxml.WebXMLAssembler.java

protected void addServlet(Extension servletExn, XMLStreamWriter xmlStreamWriter) throws XMLStreamException {
    String servletName = servletExn.getParameter("servlet-name").valueAsString();
    String servletClass = servletExn.getParameter("servlet-class").valueAsString();
    xmlStreamWriter.writeStartElement("xsl:if");
    xmlStreamWriter.writeAttribute("test", "count(tp:servlet[tp:servlet-name = '" + servletName + "']) = 0");
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("servlet");
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("servlet-name");
    xmlStreamWriter.writeCharacters(servletName);
    xmlStreamWriter.writeEndElement();//from  ww w.  ja v a2 s .com
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("servlet-class");
    xmlStreamWriter.writeCharacters(servletClass);
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
    for (Parameter param : servletExn.getParameters("init-param")) {
        xmlStreamWriter.writeStartElement("init-param");
        String paramName = param.getSubParameter("param-name").valueAsString();
        xmlStreamWriter.writeStartElement("param-name");
        xmlStreamWriter.writeCharacters(paramName);
        xmlStreamWriter.writeEndElement();
        xmlStreamWriter.writeCharacters("\n");
        String paramValue = param.getSubParameter("param-value").valueAsString();
        xmlStreamWriter.writeStartElement("param-value");
        xmlStreamWriter.writeCharacters(paramValue);
        xmlStreamWriter.writeEndElement();
        xmlStreamWriter.writeCharacters("\n");
        xmlStreamWriter.writeEndElement();
        xmlStreamWriter.writeCharacters("\n");
    }
    if (servletExn.getParameter("load-on-startup") != null) {
        Number loadOnStartUp = servletExn.getParameter("load-on-startup").valueAsNumber();
        xmlStreamWriter.writeStartElement("load-on-startup");
        xmlStreamWriter.writeCharacters(loadOnStartUp.toString());
        xmlStreamWriter.writeEndElement();
        xmlStreamWriter.writeCharacters("\n");
    }
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
}

From source file:org.tolven.assembler.webxml.WebXMLAssembler.java

protected void addServletMapping(String servletName, String urlPattern, XMLStreamWriter xmlStreamWriter)
        throws XMLStreamException {
    xmlStreamWriter.writeStartElement("xsl:if");
    xmlStreamWriter.writeAttribute("test", "count(tp:servlet-mapping[tp:servlet-name = '" + servletName
            + "' and tp:url-pattern = '" + urlPattern + "']) = 0");
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("servlet-mapping");
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("servlet-name");
    xmlStreamWriter.writeCharacters(servletName);
    xmlStreamWriter.writeEndElement();/* w ww.j av a  2 s .  c  om*/
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("url-pattern");
    xmlStreamWriter.writeCharacters(urlPattern);
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
}

From source file:org.tolven.assembler.webxml.WebXMLAssembler.java

protected void addServletTemplates(PluginDescriptor pd, XMLStreamWriter xmlStreamWriter)
        throws XMLStreamException {
    xmlStreamWriter.writeStartElement("xsl:template");
    xmlStreamWriter.writeAttribute("name", "addServlets");
    xmlStreamWriter.writeCharacters("\n");
    List<Extension> servletExtensions = getServletExtensions(pd);
    Map<String, Map<String, Object>> servletMappings = getServletMappings(pd, servletExtensions);
    for (Extension exn : servletExtensions) {
        String servletName = exn.getParameter("servlet-name").valueAsString();
        addServlet(exn, xmlStreamWriter);
        Set<String> urlPatterns = new HashSet<String>();
        Map<String, Object> map = servletMappings.get(servletName);
        if (map != null) {
            List<Extension> mappingExns = (List<Extension>) map.get("mappings");
            for (Extension mappingExn : mappingExns) {
                for (Parameter param : mappingExn.getParameters("url-pattern")) {
                    urlPatterns.add(param.valueAsString());
                }//from  ww  w  .  j a  v a2s. c  o m
            }
        }
        for (String urlPattern : urlPatterns) {
            addServletMapping(servletName, urlPattern, xmlStreamWriter);
        }
    }
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
}

From source file:org.tolven.assembler.webxml.WebXMLAssembler.java

protected void addSessionConfig(Number sessionTimeout, XMLStreamWriter xmlStreamWriter)
        throws XMLStreamException {
    xmlStreamWriter.writeStartElement("xsl:if");
    xmlStreamWriter.writeAttribute("test",
            "count(tp:session-config[tp:session-timeout = '" + sessionTimeout + "']) = 0");
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("session-config");
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("session-timeout");
    xmlStreamWriter.writeCharacters(sessionTimeout.toString());
    xmlStreamWriter.writeEndElement();/* w w  w.  ja  va2  s.  c  o  m*/
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
}

From source file:org.tolven.assembler.webxml.WebXMLAssembler.java

protected void addSessionConfigTemplates(PluginDescriptor pd, XMLStreamWriter xmlStreamWriter)
        throws XMLStreamException {
    xmlStreamWriter.writeStartElement("xsl:template");
    xmlStreamWriter.writeAttribute("name", "addSessionConfigs");
    xmlStreamWriter.writeCharacters("\n");
    for (Extension exn : getExtensions(pd, "session-config")) {
        addSessionConfig(exn.getParameter("session-timeout").valueAsNumber(), xmlStreamWriter);
    }/*from w ww  .  j av  a  2s.  c om*/
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
}

From source file:org.tolven.assembler.webxml.WebXMLAssembler.java

protected void addTagLibContextParameterCallTemplate(String tagLib, boolean semicolonSeparator,
        String templateName1, String templateName2, XMLStreamWriter xmlStreamWriter) throws XMLStreamException {
    xmlStreamWriter.writeStartElement("xsl:template");
    xmlStreamWriter.writeAttribute("name", templateName1);
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("xsl:param");
    xmlStreamWriter.writeAttribute("name", "param-name");
    xmlStreamWriter.writeEndElement();/*  ww  w.ja  va  2s  . co  m*/
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("xsl:param");
    xmlStreamWriter.writeAttribute("name", "param-value");
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("xsl:choose");
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("xsl:when");
    xmlStreamWriter.writeAttribute("test", "contains($param-value, '" + tagLib + "')");
    xmlStreamWriter.writeCharacters("\n");
    addTagLibContextParameterWhenCallTemplate(templateName2, xmlStreamWriter);
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeStartElement("xsl:otherwise");
    xmlStreamWriter.writeCharacters("\n");
    addTagLibContextParameterOtherwiseCallTemplate(templateName2, tagLib, semicolonSeparator, xmlStreamWriter);
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
}