Example usage for javax.xml.soap SOAPElement lookupPrefix

List of usage examples for javax.xml.soap SOAPElement lookupPrefix

Introduction

In this page you can find the example usage for javax.xml.soap SOAPElement lookupPrefix.

Prototype

public String lookupPrefix(String namespaceURI);

Source Link

Document

Look up the prefix associated to the given namespace URI, starting from this node.

Usage

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

/**
 * Test that a call do {@link SOAPElement#addNamespaceDeclaration(String, String)} for a prefix
 * that is already declared on the same element will replace the existing namespace declaration.
 * /*w w w . j av  a 2  s  .c  o  m*/
 * @throws SOAPException
 */
@Validated
@Test
public void testAddNamespaceDeclarationForExistingPrefix() throws SOAPException {
    SOAPElement element = saajUtil.createSOAPElement(null, "test", null);
    element.addNamespaceDeclaration("p", "urn:ns1");
    element.addNamespaceDeclaration("p", "urn:ns2");
    assertEquals("urn:ns2", element.lookupNamespaceURI("p"));
    assertNull(element.lookupPrefix("urn:ns1"));
    assertEquals("p", element.lookupPrefix("urn:ns2"));
}