List of usage examples for javax.xml.soap SOAPElement setPrefix
public void setPrefix(String prefix) throws DOMException;
null
if it is unspecified. From source file:org.apache.axis2.jaxws.message.util.impl.SAAJConverterImpl.java
/** * update the tag data of the SOAPElement * * @param NameCreator nc//from w ww . ja v a 2s.c om * @param element SOAPElement * @param reader XMLStreamReader whose cursor is at START_ELEMENT */ protected void updateTagData(NameCreator nc, SOAPElement element, XMLStreamReader reader, boolean newElement) throws SOAPException { String prefix = reader.getPrefix(); prefix = (prefix == null) ? "" : prefix; // Make sure the prefix is correct if (prefix.length() > 0 && !element.getPrefix().equals(prefix)) { // Due to a bug in Axiom DOM or in the reader...not sure where yet, // there may be a non-null prefix and no namespace String ns = reader.getNamespaceURI(); if (ns != null && ns.length() != 0) { element.setPrefix(prefix); } } if (!newElement) { // Add the namespace declarations from the reader for the missing namespaces int size = reader.getNamespaceCount(); for (int i = 0; i < size; i++) { String pre = reader.getNamespacePrefix(i); String ns = reader.getNamespaceURI(i); if ((pre != null && pre.length() > 0) && (ns == null || ns.length() == 0)) { if (log.isDebugEnabled()) { log.debug("The prefix is (" + pre + ") but there is no namespace. " + "This erroneous declaration is skipped."); } } else { String existingNS = element.getNamespaceURI(pre); if (!ns.equals(existingNS)) { element.removeNamespaceDeclaration(pre); // Is it necessary to remove the existing prefix/ns element.addNamespaceDeclaration(pre, ns); } } } } else { // Add the namespace declarations from the reader int size = reader.getNamespaceCount(); for (int i = 0; i < size; i++) { String newPrefix = reader.getNamespacePrefix(i); String newNS = reader.getNamespaceURI(i); if ((newPrefix != null && newPrefix.length() > 0) && (newNS == null || newNS.length() == 0)) { // Due to a bug in Axiom DOM or the reader, I have // seen cases where the prefix is non-null but there is not // namespace. Example: prefix is axis2ns3 and namespace is null. // This is an error..log, tolerate and continue if (log.isDebugEnabled()) { log.debug("The prefix is (" + newPrefix + ") but there is no namespace. " + "This erroneous declaration is skipped."); } } else { element.addNamespaceDeclaration(newPrefix, newNS); } } } addAttributes(nc, element, reader); return; }