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.assembler.ear.EARAssembler.java

protected void addRootSecurityRoleSelects(XMLStreamWriter writer) throws XMLStreamException {
    writer.writeStartElement("xsl:for-each");
    writer.writeAttribute("select", "tp:security-role");
    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  .ja v a2s .co  m
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
    writer.writeStartElement("xsl:call-template");
    writer.writeAttribute("name", "addSecurityRoles");
    writer.writeEndElement();
    writer.writeCharacters("\n");
}

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

protected void addRootTemplate(XMLStreamWriter writer) throws XMLStreamException {
    writer.writeStartElement("xsl:template");
    writer.writeAttribute("match", "tp:application");
    writer.writeCharacters("\n");
    writer.writeStartElement("application");
    writer.writeAttribute("version", "{@version}");
    writer.writeAttribute("xmlns", "http://java.sun.com/xml/ns/javaee");
    writer.writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
    writer.writeAttribute("xsi:schemaLocation",
            "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd");
    writer.writeCharacters("\n");
    addRootDisplayName(writer);/* w  ww  . j a v a2  s. c  o m*/
    addRootConnectorModuleSelects(writer);
    addRootEJBModuleSelects(writer);
    addRootWEBModuleSelects(writer);
    addRootSecurityRoleSelects(writer);
    writer.writeEndElement();
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
}

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

protected void addRootWEBModuleSelects(XMLStreamWriter writer) throws XMLStreamException {
    writer.writeStartElement("xsl:for-each");
    writer.writeAttribute("select", "tp:module/tp:web");
    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();//  w w  w.j  av  a 2 s.c o  m
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
    writer.writeStartElement("xsl:call-template");
    writer.writeAttribute("name", "addWEBModules");
    writer.writeEndElement();
    writer.writeCharacters("\n");
}

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

protected void addSecurityRoles(String description, String roleName, XMLStreamWriter writer)
        throws XMLStreamException {
    writer.writeStartElement("xsl:if");
    writer.writeAttribute("test", "count(security-role/role-name[text() = '" + roleName + "']) = 0");
    writer.writeCharacters("\n");
    writer.writeStartElement("security-role");
    writer.writeCharacters("\n");
    if (description != null) {
        writer.writeStartElement("description");
        writer.writeCharacters(description);
        writer.writeEndElement();/* ww  w.  j a v a2 s .co m*/
        writer.writeCharacters("\n");
    }
    writer.writeStartElement("role-name");
    writer.writeCharacters(roleName);
    writer.writeEndElement();
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
}

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

protected void addSecurityRoleTemplates(PluginDescriptor pd, XMLStreamWriter writer) throws XMLStreamException {
    writer.writeStartElement("xsl:template");
    writer.writeAttribute("name", "addSecurityRoles");
    writer.writeCharacters("\n");
    ExtensionPoint exnPt = pd.getExtensionPoint(EXNPT_SECURITY_ROLE);
    if (exnPt != null) {
        for (Extension exn : exnPt.getConnectedExtensions()) {
            String description = null;
            if (exn.getParameter("description") != null) {
                description = exn.getParameter("description").valueAsString();
            }/*  ww w.  jav  a  2  s .  c  o m*/
            String roleName = exn.getParameter("role-name").valueAsString();
            addSecurityRoles(description, roleName, writer);
        }
        writer.writeEndElement();
        writer.writeCharacters("\n");
    }
}

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

protected void addWARModuleTemplates(PluginDescriptor pd, File localDestDir, XMLStreamWriter writer)
        throws XMLStreamException, IOException {
    writer.writeStartElement("xsl:template");
    writer.writeAttribute("name", "addWEBModules");
    writer.writeCharacters("\n");
    assembleWARModules(pd, writer);//from  w  w  w . j a  va 2 s .  c  o  m
    assembleWARModuleProducts(pd, localDestDir, writer);
    assembleWARModuleProductsPlugins(pd, localDestDir, writer);
    assembleWARModuleAdaptors(pd, writer);
    writer.writeEndElement();
    writer.writeCharacters("\n");
}

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

protected void addWebModules(String webURI, String contextRoot, XMLStreamWriter writer)
        throws XMLStreamException {
    writer.writeStartElement("xsl:if");
    writer.writeAttribute("test", "count(module/web-uri[text() = '" + webURI + "']) = 0");
    writer.writeCharacters("\n");
    writer.writeStartElement("module");
    writer.writeCharacters("\n");
    writer.writeStartElement("web");
    writer.writeCharacters("\n");
    writer.writeStartElement("web-uri");
    writer.writeCharacters(webURI);// w  w w.  j ava  2s .co m
    writer.writeEndElement();
    writer.writeCharacters("\n");
    writer.writeStartElement("context-root");
    writer.writeCharacters(contextRoot);
    writer.writeEndElement();
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
    writer.writeEndElement();
    writer.writeCharacters("\n");
}

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

protected String getXSLT(PluginDescriptor pd, File localDestDir) throws XMLStreamException, IOException {
    StringWriter xslt = new StringWriter();
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    XMLStreamWriter writer = null;
    try {/*  w w w.j a va2  s.c o m*/
        writer = factory.createXMLStreamWriter(xslt);
        writer.writeStartDocument("UTF-8", "1.0");
        writer.writeCharacters("\n");
        writer.writeStartElement("xsl:stylesheet");
        writer.writeAttribute("version", "2.0");
        writer.writeNamespace("xsl", "http://www.w3.org/1999/XSL/Transform");
        writer.writeNamespace("tp", "http://java.sun.com/xml/ns/javaee");
        writer.writeCharacters("\n");
        writer.writeStartElement("xsl:output");
        writer.writeAttribute("method", "xml");
        writer.writeAttribute("indent", "yes");
        writer.writeAttribute("encoding", "UTF-8");
        writer.writeAttribute("omit-xml-declaration", "no");
        writer.writeEndElement();
        writer.writeCharacters("\n");
        addMainTemplate(writer);
        addRootTemplate(writer);
        addJavaLibraryTemplates(pd, localDestDir);
        addConnectorModuleTemplates(pd, localDestDir, writer);
        addEJBModuleTemplates(pd, localDestDir, writer);
        addWARModuleTemplates(pd, localDestDir, writer);
        addSecurityRoleTemplates(pd, writer);
        writer.writeEndDocument();
        writer.writeEndDocument();
    } finally {
        if (writer != null) {
            writer.close();
        }
    }
    return xslt.toString();
}

From source file:org.tolven.assembler.ejbmodule.EJBModuleAssembler.java

protected void addAssemblyDescriptorChildren(XMLStreamWriter xmlStreamWriter) throws XMLStreamException {
    xmlStreamWriter.writeStartElement("xsl:template");
    xmlStreamWriter.writeAttribute("name", "addAssemblyDescriptorChildren");
    xmlStreamWriter.writeCharacters("\n");
    xmlStreamWriter.writeEndElement();//from  w  ww .j a  v a2 s  . c  o m
    xmlStreamWriter.writeCharacters("\n");
    addAssemblyDescriptorCreate(false, xmlStreamWriter);
}

From source file:org.tolven.assembler.ejbmodule.EJBModuleAssembler.java

protected void addAssemblyDescriptorCreate(boolean hasAssemblyDescriptor, XMLStreamWriter xmlStreamWriter)
        throws XMLStreamException {
    xmlStreamWriter.writeStartElement("xsl:template");
    xmlStreamWriter.writeAttribute("name", "createAssemblyDescriptor");
    xmlStreamWriter.writeCharacters("\n");
    if (hasAssemblyDescriptor) {
        logger.debug("AssemblyDescriptor tag will be created");
        xmlStreamWriter.writeStartElement("assembly-descriptor");
        xmlStreamWriter.writeCharacters("\n");
        xmlStreamWriter.writeStartElement("xsl:call-template");
        xmlStreamWriter.writeAttribute("name", "createAssemblyDescriptorChildren");
        xmlStreamWriter.writeEndElement();
        xmlStreamWriter.writeCharacters("\n");
        xmlStreamWriter.writeEndElement();
        xmlStreamWriter.writeCharacters("\n");
    } else {//from w  w w.j a v a 2 s  .c  om
        logger.debug("No assembly-descriptor tag will be created");
    }
    xmlStreamWriter.writeEndElement();
    xmlStreamWriter.writeCharacters("\n");
}