Example usage for org.w3c.dom Element setAttributeNS

List of usage examples for org.w3c.dom Element setAttributeNS

Introduction

In this page you can find the example usage for org.w3c.dom Element setAttributeNS.

Prototype

public void setAttributeNS(String namespaceURI, String qualifiedName, String value) throws DOMException;

Source Link

Document

Adds a new attribute.

Usage

From source file:bpsperf.modelgen.BPMNGenerator.java

public void generateServiceTaskSequence(int numNodes, String serviceClass) throws Exception {

    Element start = addNode(startEvent, "startEvent");
    Element rtaskS = null;//from w  w  w .j  ava  2  s  .  co  m
    for (int i = 1; i <= numNodes; i++) {

        Element rtask = addNode(serviceTask, "st" + i);
        rtask.setAttributeNS(activitins, "class", serviceClass);

        if (rtaskS == null) {
            connect(start, rtask);
        } else {
            connect(rtaskS, rtask);
        }
        rtaskS = rtask;
    }

    Element end = addNode(endEvent, "endEvent");
    connect(rtaskS, end);
}

From source file:bpsperf.modelgen.BPMNGenerator.java

public void generateXORServiceTasks(int numGateways, String serviceClass) throws Exception {

    Element start = addNode(startEvent, "startEvent");
    Element end = addNode(endEvent, "endEvent");
    Element xorS = null;/*from  w  ww .j ava 2 s  .  c  o m*/
    for (int i = 1; i <= numGateways; i++) {

        Element xor = addNode(xorGateway, "xor" + i);

        Element task = addNode(serviceTask, "st" + i);
        task.setAttributeNS(activitins, "class", serviceClass);
        Element defaultFlow = connect(xor, task);
        xor.setAttribute("default", defaultFlow.getAttribute("id"));
        connect(task, end);

        if (xorS == null) {
            connect(start, xor);
        } else {
            Element conFlow = connect(xorS, xor);
            Element condition = addElement(conFlow, ns, "conditionExpression");
            condition.setAttributeNS(xsins, "type", "tFormalExpression");
            CDATASection expression = doc.createCDATASection("${v1 >= " + i + "}");
            condition.appendChild(expression);
        }
        xorS = xor;
    }

    Element conditionTask = addNode(serviceTask, "st_condition");
    conditionTask.setAttributeNS(activitins, "class", serviceClass);
    Element lastConFlow = connect(xorS, conditionTask);
    Element condition = addElement(lastConFlow, ns, "conditionExpression");
    condition.setAttributeNS(xsins, "type", "tFormalExpression");
    CDATASection expression = doc.createCDATASection("${v1 > 10000}");
    condition.appendChild(expression);
    connect(conditionTask, end);
}

From source file:bpsperf.modelgen.BPMNGenerator.java

private Element[] generateSequence(String serviceClass, int seqNumber, int length) {

    Element[] terminals = new Element[2];

    Element rtaskS = null;/*  w ww.j  a v  a 2 s  .  c  om*/
    for (int i = 1; i <= numNodes; i++) {
        Element rtask = addNode(serviceTask, "st" + seqNumber + "_" + i);
        rtask.setAttributeNS(activitins, "class", serviceClass);

        if (rtaskS == null) {
            terminals[0] = rtask;
        } else {
            connect(rtaskS, rtask);
        }
        rtaskS = rtask;
    }
    terminals[1] = rtaskS;
    return terminals;
}

From source file:bpsperf.modelgen.BPMNGenerator.java

public void generateRESTTaskSequence(int numNodes, String serviceURL) throws Exception {

    Element start = addNode(startEvent, "startEvent");
    Element rtaskS = null;/*from w ww. j a v a2 s. c o m*/
    for (int i = 1; i <= numNodes; i++) {

        Element rtask = addNode(serviceTask, "rt" + i);
        rtask.setAttributeNS(activitins, "class", "org.wso2.carbon.bpmn.extensions.rest.SyncInvokeTask");
        Element extensions = addElement(rtask, ns, "extensionElements");

        Element serviceURLField = addElement(extensions, activitins, "field");
        serviceURLField.setAttribute("name", "serviceURL");
        Element expression1 = addElement(serviceURLField, activitins, "expression");
        expression1.setTextContent(serviceURL);

        Element methodField = addElement(extensions, activitins, "field");
        methodField.setAttribute("name", "method");
        Element expression2 = addElement(methodField, activitins, "string");
        CDATASection postData = doc.createCDATASection("POST");
        expression2.appendChild(postData);

        Element inputField = addElement(extensions, activitins, "field");
        inputField.setAttribute("name", "input");
        Element expression3 = addElement(inputField, activitins, "expression");
        expression3.setTextContent("Message sent from: rt" + i);

        Element voutField = addElement(extensions, activitins, "field");
        voutField.setAttribute("name", "vout");
        Element expression4 = addElement(voutField, activitins, "string");
        CDATASection outvarData = doc.createCDATASection("outvar1");
        expression4.appendChild(outvarData);

        if (rtaskS == null) {
            connect(start, rtask);
        } else {
            connect(rtaskS, rtask);
        }
        rtaskS = rtask;
    }

    Element end = addNode(endEvent, "endEvent");
    connect(rtaskS, end);
}

From source file:com.evolveum.midpoint.util.DOMUtil.java

public static void setNill(Element element) {
    element.setAttributeNS(XSI_NIL.getNamespaceURI(), XSI_NIL.getLocalPart(), "true");
}

From source file:fr.ortolang.diffusion.seo.SeoServiceBean.java

private Document generateSiteMapDocument() throws ParserConfigurationException, SeoServiceException {
    DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
    Document doc = docBuilder.newDocument();

    Element urlset = doc.createElement("urlset");
    urlset.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", SITEMAP_NS_URI);

    String marketServerUrl = OrtolangConfig.getInstance()
            .getProperty(OrtolangConfig.Property.MARKET_SERVER_URL);

    generateMarketSectionEntries(urlset, doc, marketServerUrl);
    generateWorkspacesEntries(urlset, doc, marketServerUrl);

    doc.appendChild(urlset);//from w  w w.j av  a 2 s .  com

    return doc;
}

From source file:be.fedict.eid.applet.service.signer.ooxml.RelationshipTransformService.java

@Override
public void marshalParams(XMLStructure parent, XMLCryptoContext context) throws MarshalException {
    LOG.debug("marshallParams(parent,context)");
    DOMStructure domParent = (DOMStructure) parent;
    Node parentNode = domParent.getNode();
    Element parentElement = (Element) parentNode;
    parentElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:mdssi",
            "http://schemas.openxmlformats.org/package/2006/digital-signature");
    Document document = parentNode.getOwnerDocument();
    for (String sourceId : this.sourceIds) {
        Element relationshipReferenceElement = document.createElementNS(
                "http://schemas.openxmlformats.org/package/2006/digital-signature",
                "mdssi:RelationshipReference");
        relationshipReferenceElement.setAttribute("SourceId", sourceId);
        parentElement.appendChild(relationshipReferenceElement);
    }/*from   w  w  w  . j a v  a  2 s .  c o  m*/
    for (String sourceType : this.sourceTypes) {
        Element relationshipsGroupReferenceElement = document.createElementNS(
                "http://schemas.openxmlformats.org/package/2006/digital-signature",
                "mdssi:RelationshipsGroupReference");
        relationshipsGroupReferenceElement.setAttribute("SourceType", sourceType);
        parentElement.appendChild(relationshipsGroupReferenceElement);
    }
}

From source file:io.wcm.tooling.commons.contentpackagebuilder.XmlContentBuilder.java

private void setAttributeNamespaceAware(Element element, String key, String value) {
    String namespace = getNamespace(key);
    if (namespace == null) {
        element.setAttribute(ISO9075.encode(key), value);
    } else {/*from  w w w  .j av a2 s.  com*/
        element.setAttributeNS(namespace, ISO9075.encode(key), value);
    }
}

From source file:be.fedict.eid.dss.spi.utils.XAdESValidation.java

private Element getNsElement(Document document) {

    Element nsElement = document.createElement("nsElement");
    nsElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:ds", Constants.SignatureSpecNS);
    nsElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:xades", XAdESUtils.XADES_132_NS_URI);
    nsElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:xades141", XAdESUtils.XADES_141_NS_URI);
    nsElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:identity", IdentitySignatureFacet.NAMESPACE_URI);
    return nsElement;
}

From source file:es.gob.afirma.signers.ooxml.be.fedict.eid.applet.service.signer.ooxml.AbstractOOXMLSignatureService.java

private ZipOutputStream copyOOXMLContent(final String signatureZipEntryName,
        final OutputStream signedOOXMLOutputStream)
        throws IOException, ParserConfigurationException, SAXException, TransformerException {
    final ZipOutputStream zipOutputStream = new ZipOutputStream(signedOOXMLOutputStream);
    final ZipInputStream zipInputStream = new ZipInputStream(
            new ByteArrayInputStream(this.getOfficeOpenXMLDocument()));
    ZipEntry zipEntry;/*from   w w w. j av a  2  s  .c  o m*/
    boolean hasOriginSigsRels = false;
    while (null != (zipEntry = zipInputStream.getNextEntry())) {
        zipOutputStream.putNextEntry(new ZipEntry(zipEntry.getName()));
        if ("[Content_Types].xml".equals(zipEntry.getName())) { //$NON-NLS-1$
            final Document contentTypesDocument = loadDocumentNoClose(zipInputStream);
            final Element typesElement = contentTypesDocument.getDocumentElement();

            // We need to add an Override element.
            final Element overrideElement = contentTypesDocument.createElementNS(
                    "http://schemas.openxmlformats.org/package/2006/content-types", "Override"); //$NON-NLS-1$ //$NON-NLS-2$
            overrideElement.setAttribute("PartName", "/" + signatureZipEntryName); //$NON-NLS-1$ //$NON-NLS-2$
            overrideElement.setAttribute("ContentType", //$NON-NLS-1$
                    "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml"); //$NON-NLS-1$
            typesElement.appendChild(overrideElement);

            final Element nsElement = contentTypesDocument.createElement("ns"); //$NON-NLS-1$
            nsElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:tns", //$NON-NLS-1$
                    "http://schemas.openxmlformats.org/package/2006/content-types"); //$NON-NLS-1$
            final NodeList nodeList = XPathAPI.selectNodeList(contentTypesDocument,
                    "/tns:Types/tns:Default[@Extension='sigs']", nsElement); //$NON-NLS-1$
            if (0 == nodeList.getLength()) {
                // Add Default element for 'sigs' extension.
                final Element defaultElement = contentTypesDocument.createElementNS(
                        "http://schemas.openxmlformats.org/package/2006/content-types", "Default"); //$NON-NLS-1$ //$NON-NLS-2$
                defaultElement.setAttribute("Extension", "sigs"); //$NON-NLS-1$ //$NON-NLS-2$
                defaultElement.setAttribute("ContentType", //$NON-NLS-1$
                        "application/vnd.openxmlformats-package.digital-signature-origin"); //$NON-NLS-1$
                typesElement.appendChild(defaultElement);
            }

            writeDocumentNoClosing(contentTypesDocument, zipOutputStream, false);
        } else if ("_rels/.rels".equals(zipEntry.getName())) { //$NON-NLS-1$
            final Document relsDocument = loadDocumentNoClose(zipInputStream);

            final Element nsElement = relsDocument.createElement("ns"); //$NON-NLS-1$
            nsElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:tns", RELATIONSHIPS_SCHEMA); //$NON-NLS-1$
            final NodeList nodeList = XPathAPI.selectNodeList(relsDocument,
                    "/tns:Relationships/tns:Relationship[@Type='http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin']", //$NON-NLS-1$
                    nsElement);
            if (0 == nodeList.getLength()) {
                final Element relationshipElement = relsDocument.createElementNS(RELATIONSHIPS_SCHEMA,
                        "Relationship"); //$NON-NLS-1$
                relationshipElement.setAttribute("Id", "rel-id-" + UUID.randomUUID().toString()); //$NON-NLS-1$ //$NON-NLS-2$
                relationshipElement.setAttribute("Type", //$NON-NLS-1$
                        "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/origin"); //$NON-NLS-1$
                relationshipElement.setAttribute("Target", "_xmlsignatures/origin.sigs"); //$NON-NLS-1$ //$NON-NLS-2$

                relsDocument.getDocumentElement().appendChild(relationshipElement);
            }

            writeDocumentNoClosing(relsDocument, zipOutputStream, false);
        } else if (zipEntry.getName().startsWith("_xmlsignatures/_rels/") //$NON-NLS-1$
                && zipEntry.getName().endsWith(".rels")) { //$NON-NLS-1$

            hasOriginSigsRels = true;
            final Document originSignRelsDocument = loadDocumentNoClose(zipInputStream);

            final Element relationshipElement = originSignRelsDocument.createElementNS(RELATIONSHIPS_SCHEMA,
                    "Relationship"); //$NON-NLS-1$
            relationshipElement.setAttribute("Id", "rel-" + UUID.randomUUID().toString()); //$NON-NLS-1$ //$NON-NLS-2$
            relationshipElement.setAttribute("Type", //$NON-NLS-1$
                    "http://schemas.openxmlformats.org/package/2006/relationships/digital-signature/signature"); //$NON-NLS-1$

            relationshipElement.setAttribute("Target", FilenameUtils.getName(signatureZipEntryName)); //$NON-NLS-1$
            originSignRelsDocument.getDocumentElement().appendChild(relationshipElement);

            writeDocumentNoClosing(originSignRelsDocument, zipOutputStream, false);
        } else {
            IOUtils.copy(zipInputStream, zipOutputStream);
        }
    }

    if (!hasOriginSigsRels) {
        // Add signature relationships document.
        addOriginSigsRels(signatureZipEntryName, zipOutputStream);
        addOriginSigs(zipOutputStream);
    }

    // Return.
    zipInputStream.close();
    return zipOutputStream;
}