Example usage for javax.xml.soap Name getQualifiedName

List of usage examples for javax.xml.soap Name getQualifiedName

Introduction

In this page you can find the example usage for javax.xml.soap Name getQualifiedName.

Prototype

String getQualifiedName();

Source Link

Document

Gets the namespace-qualified name of the XML name that this Name object represents.

Usage

From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java

/**
 * Test that {@link SOAPElement#getAllAttributes()} returns the correct {@link Name} for an
 * attribute with a namespace./*from  w w w .j ava  2 s.c o  m*/
 */
@Validated
@Test
public void testGetAllAttributesWithNamespace() {
    SOAPElement element = saajUtil.createSOAPElement(null, "test", null);
    element.setAttributeNS("urn:ns", "p:test", "value");
    Iterator<?> it = element.getAllAttributes();
    assertTrue(it.hasNext());
    Name name = (Name) it.next();
    assertEquals("urn:ns", name.getURI());
    assertEquals("p", name.getPrefix());
    assertEquals("test", name.getLocalName());
    assertEquals("p:test", name.getQualifiedName());
}

From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java

/**
 * Test that {@link SOAPElement#getAllAttributes()} returns the correct {@link Name} for an
 * attribute without namespace./*  w  w  w  . j  a v a 2 s. co  m*/
 */
@Validated
@Test
public void testGetAllAttributesWithoutNamespace() {
    SOAPElement element = saajUtil.createSOAPElement(null, "test", null);
    element.setAttributeNS(null, "test", "value");
    Iterator<?> it = element.getAllAttributes();
    assertTrue(it.hasNext());
    Name name = (Name) it.next();
    assertTrue(StringUtils.isEmpty(name.getURI()));
    assertTrue(StringUtils.isEmpty(name.getPrefix()));
    assertEquals("test", name.getLocalName());
    assertEquals("test", name.getQualifiedName());
}

From source file:org.jbpm.bpel.integration.soap.SoapUtil.java

public static void copyAttributes(Element target, SOAPElement source) {
    // easy way out: no attributes to copy
    if (!source.hasAttributes())
        return;// www .java 2 s . co  m
    // traverse attributes
    Iterator attrNameIt = source.getAllAttributes();
    while (attrNameIt.hasNext()) {
        Name attrName = (Name) attrNameIt.next();
        String namespaceURI = attrName.getURI();

        // isn't the attribute a namespace declaration?
        if (BpelConstants.NS_XMLNS.equals(namespaceURI))
            continue;

        // unqualified?
        if (namespaceURI == null || namespaceURI.length() == 0) {
            String localName = attrName.getLocalName();
            target.setAttribute(localName, source.getAttributeValue(attrName));
            if (traceEnabled)
                log.trace("set attribute: " + localName);
        }
        // qualified
        else {
            Attr attr = target.getOwnerDocument().createAttributeNS(namespaceURI, attrName.getQualifiedName());
            attr.setValue(source.getAttributeValue(attrName));
            target.setAttributeNodeNS(attr);
            XmlUtil.ensureNamespaceDeclared(attr, namespaceURI, attrName.getPrefix());
            if (traceEnabled)
                log.trace("set attribute: {" + namespaceURI + '}' + attrName.getQualifiedName());
        }
    }
}