Esempio n. 1
0
 public static void copyAttributes(SOAPElement target, Element source) {
   // easy way out: no attributes
   if (!source.hasAttributes()) return;
   final boolean traceEnabled = log.isTraceEnabled();
   // traverse attributes
   NamedNodeMap attributes = source.getAttributes();
   for (int i = 0, n = attributes.getLength(); i < n; i++) {
     Node attribute = attributes.item(i);
     String namespaceURI = attribute.getNamespaceURI();
     // isn't the attribute a namespace declaration?
     if (!BpelConstants.NS_XMLNS.equals(namespaceURI)) {
       String name = attribute.getNodeName();
       String value = attribute.getNodeValue();
       if (namespaceURI == null) {
         /*
          * use the DOM level 1 method as some SAAJ implementations complain
          * when presented a null namespace URI
          */
         target.setAttribute(name, value);
       } else {
         target.setAttributeNS(namespaceURI, name, value);
       }
       if (traceEnabled) log.trace("set attribute: " + name);
     }
   }
 }
Esempio n. 2
0
 public static void copyNamespaces(SOAPElement target, Element source) throws SOAPException {
   // easy way out: no attributes
   if (!source.hasAttributes()) return;
   final boolean traceEnabled = log.isTraceEnabled();
   // traverse attributes to discover namespace declarations
   NamedNodeMap attributes = source.getAttributes();
   for (int i = 0, n = attributes.getLength(); i < n; i++) {
     Node attribute = attributes.item(i);
     // is attribute a namespace declaration?
     if (!BpelConstants.NS_XMLNS.equals(attribute.getNamespaceURI())) continue;
     // namespace declaration format xmlns:prefix="namespaceURI" |
     // xmlns="defaultNamespaceURI"
     String namespaceURI = attribute.getNodeValue();
     String prefix = attribute.getLocalName();
     // non-default namespace declaration?
     if (!"xmlns".equals(prefix)) {
       // BPEL-195: prevent addition matching visible declaration at target
       if (namespaceURI.equals(target.getNamespaceURI(prefix))) continue;
       target.addNamespaceDeclaration(prefix, namespaceURI);
       if (traceEnabled) log.trace("added namespace declaration: " + prefix + "->" + namespaceURI);
     }
     // non-empty default namespace declaration
     else if (namespaceURI.length() > 0) {
       prefix = generatePrefix(source, DEFAULT_NAMESPACE_PREFIX);
       target.addNamespaceDeclaration(prefix, namespaceURI);
       if (traceEnabled)
         log.trace("reassigned default namespace declaration: " + prefix + "->" + namespaceURI);
     }
   }
 }
Esempio n. 3
0
 public static void copyNamespaces(final Element target, Element source) {
   // easy way out: no attributes
   if (!source.hasAttributes()) return;
   final boolean traceEnabled = log.isTraceEnabled();
   // traverse attributes to discover namespace declarations
   NamedNodeMap attributes = source.getAttributes();
   for (int i = 0, n = attributes.getLength(); i < n; i++) {
     Node attribute = attributes.item(i);
     // is attribute a namespace declaration?
     if (!BpelConstants.NS_XMLNS.equals(attribute.getNamespaceURI())) continue;
     // namespace declaration format xmlns:prefix="namespaceURI" |
     // xmlns="defaultNamespaceURI"
     String namespaceURI = attribute.getNodeValue();
     String prefix = attribute.getLocalName();
     // default namespace declaration?
     if ("xmlns".equals(prefix)) {
       // BPEL-195: prevent addition matching visible declaration at target
       if ("".equals(getPrefix(namespaceURI, target))) continue;
       addNamespaceDeclaration(target, namespaceURI);
       if (traceEnabled) log.trace("added default namespace declaration: " + namespaceURI);
     } else {
       // BPEL-195: prevent addition matching visible declaration at target
       if (prefix.equals(getPrefix(namespaceURI, target))) continue;
       addNamespaceDeclaration(target, namespaceURI, prefix);
       if (traceEnabled) log.trace("added namespace declaration: " + prefix + "->" + namespaceURI);
     }
   }
 }
Esempio n. 4
0
 public static void copyAttributes(Element target, Element source) {
   // easy way out: no attributes
   if (!source.hasAttributes()) return;
   // traverse attributes
   NamedNodeMap attributes = source.getAttributes();
   for (int i = 0, n = attributes.getLength(); i < n; i++) {
     Node attribute = attributes.item(i);
     String namespaceURI = attribute.getNamespaceURI();
     // isn't the attribute a namespace declaration?
     if (!BpelConstants.NS_XMLNS.equals(namespaceURI)) {
       target.setAttributeNS(namespaceURI, attribute.getNodeName(), attribute.getNodeValue());
     }
   }
 }