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:org.jbpm.bpel.xml.util.XmlUtil.java

public static void addNamespaceDeclaration(Element elem, String namespaceURI) {
    elem.setAttributeNS(BpelConstants.NS_XMLNS, "xmlns", namespaceURI);
}

From source file:org.jbpm.bpel.xml.util.XmlUtil.java

public static void addNamespaceDeclaration(Element elem, String namespaceURI, String prefix) {
    elem.setAttributeNS(BpelConstants.NS_XMLNS, "xmlns:" + prefix, namespaceURI);
}

From source file:org.ojbc.util.helper.NIEMXMLUtils.java

public static Element createPersonNameElement(Document doc, String personGivenName,
        SearchFieldMetadata personGivenNameMetaData, String personMiddleName, String personSurName,
        SearchFieldMetadata personSurNameMetaData) {

    //Set Person Name
    Element personNameElement = doc.createElementNS(NIEMNamespaces.NC_20_NS, "PersonName");

    if (StringUtils.isNotBlank(personGivenName)) {
        Element personGivenNameElement = doc.createElementNS(NIEMNamespaces.NC_20_NS, "PersonGivenName");
        personGivenNameElement.setTextContent(personGivenName);
        personNameElement.appendChild(personGivenNameElement);

        if (personGivenNameMetaData == SearchFieldMetadata.ExactMatch) {
            personGivenNameElement.setAttributeNS(NIEMNamespaces.STRUCT_NS, "metadata", "SM001");
        }//  www.j a  va2  s.co m
        if (personGivenNameMetaData == SearchFieldMetadata.StartsWith) {
            personGivenNameElement.setAttributeNS(NIEMNamespaces.STRUCT_NS, "metadata", "SM002");
        }

    }

    if (StringUtils.isNotBlank(personMiddleName)) {
        Element personMiddleNameElement = doc.createElementNS(NIEMNamespaces.NC_20_NS, "PersonMiddleName");
        personMiddleNameElement.setTextContent(personMiddleName);
        personNameElement.appendChild(personMiddleNameElement);
    }

    if (StringUtils.isNotBlank(personSurName)) {
        Element personSurNameElement = doc.createElementNS(NIEMNamespaces.NC_20_NS, "PersonSurName");
        personSurNameElement.setTextContent(personSurName);
        personNameElement.appendChild(personSurNameElement);

        if (personSurNameMetaData == SearchFieldMetadata.ExactMatch) {
            personSurNameElement.setAttributeNS(NIEMNamespaces.STRUCT_NS, "metadata", "SM001");
        }
        if (personSurNameMetaData == SearchFieldMetadata.StartsWith) {
            personSurNameElement.setAttributeNS(NIEMNamespaces.STRUCT_NS, "metadata", "SM002");
        }

    }

    return personNameElement;
}

From source file:org.ojbc.util.helper.NIEMXMLUtils.java

public static Element createPersonsSearchRequestElement(Document doc, String id) {
    Element element = doc.createElementNS(OJBNamespaces.PERSON_SEARCH_REQUEST, "PersonSearchRequest");
    element.setAttributeNS(NIEMNamespaces.STRUCT_NS, "id", "SM003");

    return element;
}

From source file:org.ojbc.util.helper.NIEMXMLUtils.java

public static Element createSearchMetaData(Document doc, String searchFieldMetaDataNamespace,
        SearchFieldMetadata searchFieldMetadata) {
    Element searchFieldMetadataElement = doc.createElementNS(searchFieldMetaDataNamespace, "SearchMetadata");

    if (searchFieldMetadata != null) {
        switch (searchFieldMetadata) {
        case ExactMatch:
            searchFieldMetadataElement.setAttributeNS(NIEMNamespaces.STRUCT_NS, "id", "SM001");
            break;
        case StartsWith:
            searchFieldMetadataElement.setAttributeNS(NIEMNamespaces.STRUCT_NS, "id", "SM002");
            break;
        default://from w  ww .ja v a 2 s  .  co  m
            break;
        }
    }

    Element searchFieldQualifierCodeElement = doc.createElementNS(searchFieldMetaDataNamespace,
            "SearchQualifierCode");

    if (searchFieldMetadata != null) {
        searchFieldQualifierCodeElement.setTextContent(searchFieldMetadata.getMetadata());
    }

    searchFieldMetadataElement.appendChild(searchFieldQualifierCodeElement);

    return searchFieldMetadataElement;
}

From source file:org.ojbc.util.helper.NIEMXMLUtils.java

public static Element createSearchMetaDataPurposeOnBehalfOf(Document doc, String searchFieldMetaDataNamespace,
        String id, String onBehalfOfText, String searchPurposeText) {
    Element searchFieldMetadataElement = doc.createElementNS(searchFieldMetaDataNamespace, "SearchMetadata");
    searchFieldMetadataElement.setAttributeNS(NIEMNamespaces.STRUCT_NS, "id", id);

    if (StringUtils.isNotBlank(onBehalfOfText)) {
        Element searchRequestOnBehalfOfTextElement = doc.createElementNS(searchFieldMetaDataNamespace,
                "SearchRequestOnBehalfOfText");
        searchRequestOnBehalfOfTextElement.setTextContent(onBehalfOfText);
        searchFieldMetadataElement.appendChild(searchRequestOnBehalfOfTextElement);
    }/*  w  w w.j a  va 2s. c  om*/

    if (StringUtils.isNotBlank(searchPurposeText)) {
        Element searchPurposeTextElement = doc.createElementNS(searchFieldMetaDataNamespace,
                "SearchPurposeText");
        searchPurposeTextElement.setTextContent(searchPurposeText);
        searchFieldMetadataElement.appendChild(searchPurposeTextElement);
    }

    return searchFieldMetadataElement;
}

From source file:org.ojbc.util.helper.NIEMXMLUtils.java

public static Element createIdentificationElementWithStructureAttrAndParent(Document doc,
        String parentElementName, String identificationID, String structureAttrName,
        String structureAttrValue) {
    Element parentElement = doc.createElementNS(NIEMNamespaces.NC_20_NS, parentElementName);
    Element identificationIDElement = doc.createElementNS(NIEMNamespaces.NC_20_NS, "IdentificationID");
    identificationIDElement.setTextContent(identificationID.trim());
    identificationIDElement.setAttributeNS(NIEMNamespaces.STRUCT_NS, structureAttrName, structureAttrValue);

    parentElement.appendChild(identificationIDElement);

    return parentElement;
}

From source file:org.ojbc.util.helper.NIEMXMLUtils.java

public static Element createIncidentElement(Document doc, String structureId) {
    Element incidentElement = doc.createElementNS(OJBNamespaces.INCIDENT_SEARCH_REQUEST_EXT, "Incident");
    incidentElement.setAttributeNS(NIEMNamespaces.STRUCT_NS, "id", structureId);

    return incidentElement;
}

From source file:org.ojbc.util.helper.NIEMXMLUtils.java

public static Element createLocationElement(Document doc, String structureId) {
    Element locationElement = doc.createElementNS(NIEMNamespaces.NC_20_NS, "Location");
    locationElement.setAttributeNS(NIEMNamespaces.STRUCT_NS, "id", structureId);

    return locationElement;
}

From source file:org.ojbc.util.helper.NIEMXMLUtils.java

public static Element createActivityLocationAssociationElement(Document doc, String activityRef,
        String locationRef) {//from w  ww.  j  a v  a  2s.co  m

    Element parentElement = doc.createElementNS(NIEMNamespaces.JXDM_41_NS, "ActivityLocationAssociation");

    Element activityReferenceElement = doc.createElementNS(NIEMNamespaces.NC_20_NS, "ActivityReference");
    activityReferenceElement.setAttributeNS(NIEMNamespaces.STRUCT_NS, "ref", activityRef);

    Element locationReferenceElement = doc.createElementNS(NIEMNamespaces.NC_20_NS, "LocationReference");
    locationReferenceElement.setAttributeNS(NIEMNamespaces.STRUCT_NS, "ref", locationRef);

    parentElement.appendChild(activityReferenceElement);
    parentElement.appendChild(locationReferenceElement);

    return parentElement;
}