OMDocument document = ... for (Iterator it = document.getDescendants(false); it.hasNext(); ) { OMNode node = (OMNode)it.next(); if (node instanceof OMElement) { OMElement element = (OMElement)node; element.setNamespace(null, false); // <-- this actually changes the namespace of the element for (Iterator it2 = element.getAllDeclaredNamespaces(); it2.hasNext(); ) { it2.next(); it2.remove(); } } }
protected Element appendElement(Element child) throws SOAPException { String namespaceURI = child.getNamespaceURI(); String prefix = child.getPrefix(); SOAPElementImpl<OMElement> childEle = (SOAPElementImpl<OMElement>)child; if (namespaceURI != null && namespaceURI.trim().length() > 0) { childEle.omTarget.setNamespace(childEle.omTarget.declareNamespace(namespaceURI, prefix)); } target.appendChild(childEle.target); childEle.setParentElement((SOAPElement)this); return childEle; }
protected Element appendElement(Element child) throws SOAPException { String namespaceURI = child.getNamespaceURI(); String prefix = child.getPrefix(); SOAPElementImpl<OMElement> childEle = (SOAPElementImpl<OMElement>)child; if (namespaceURI != null && namespaceURI.trim().length() > 0) { childEle.omTarget.setNamespace(childEle.omTarget.declareNamespace(namespaceURI, prefix)); } target.appendChild(childEle.target); childEle.setParentElement((SOAPElement)this); return childEle; }
@Override protected Element appendElement(Element child) throws SOAPException { String namespaceURI = child.getNamespaceURI(); String prefix = child.getPrefix(); SOAPBodyElementImpl<?> childEle = toSOAPBodyElement(child); if (namespaceURI != null && namespaceURI.trim().length() > 0) { childEle.omTarget.setNamespace(childEle.omTarget.declareNamespace(namespaceURI, prefix)); } target.appendChild(childEle.target); childEle.setParentElement(this); return childEle; }
@Override protected Element appendElement(Element child) throws SOAPException { String namespaceURI = child.getNamespaceURI(); String prefix = child.getPrefix(); SOAPBodyElementImpl<?> childEle = toSOAPBodyElement(child); if (namespaceURI != null && namespaceURI.trim().length() > 0) { childEle.omTarget.setNamespace(childEle.omTarget.declareNamespace(namespaceURI, prefix)); } target.appendChild(childEle.target); childEle.setParentElement(this); return childEle; }
public SOAPElement setElementQName(QName newName) throws SOAPException { String localName = this.target.getLocalName(); if (org.apache.axiom.soap.SOAPConstants.BODY_LOCAL_NAME.equals(localName) || org.apache.axiom.soap.SOAPConstants.HEADER_LOCAL_NAME.equals(localName) || org.apache.axiom.soap.SOAPConstants.SOAPENVELOPE_LOCAL_NAME .equals(localName)) { throw new SOAPException("changing this element name is not allowed"); } OMNamespace omNamespace = omTarget.getOMFactory().createOMNamespace(newName.getNamespaceURI(), newName.getPrefix()); this.omTarget.setNamespace(omNamespace); this.omTarget.setLocalName(newName.getLocalPart()); return this; }
public SOAPElement setElementQName(QName newName) throws SOAPException { String localName = this.target.getLocalName(); if (org.apache.axiom.soap.SOAPConstants.BODY_LOCAL_NAME.equals(localName) || org.apache.axiom.soap.SOAPConstants.HEADER_LOCAL_NAME.equals(localName) || org.apache.axiom.soap.SOAPConstants.SOAPENVELOPE_LOCAL_NAME .equals(localName)) { throw new SOAPException("changing this element name is not allowed"); } OMNamespace omNamespace = omTarget.getOMFactory().createOMNamespace(newName.getNamespaceURI(), newName.getPrefix()); this.omTarget.setNamespace(omNamespace); this.omTarget.setLocalName(newName.getLocalPart()); return this; }
/** * Set relevant xacml namespace to all the children in the given iterator. * * * @param iterator: Iterator for all children inside OMElement */ private static void setXACMLNamespace(Iterator iterator) { while (iterator.hasNext()) { OMElement omElement2 = (OMElement) iterator.next(); omElement2.setNamespace(xacmlContextNS); if (omElement2.getChildElements().hasNext()) { setXACMLNamespace(omElement2.getChildElements()); } } }
/** * Set relevant xacml namespace to all the children in the given iterator. * * * @param iterator: Iterator for all children inside OMElement */ private static void setXACMLNamespace(Iterator iterator) { while (iterator.hasNext()) { OMElement omElement2 = (OMElement) iterator.next(); omElement2.setNamespace(xacmlContextNS); if (omElement2.getChildElements().hasNext()) { setXACMLNamespace(omElement2.getChildElements()); } } }
/** * Set relevant xacml namespace to all the children in the given iterator. * * @param iterator: Iterator for all children inside OMElement */ private static void setXACMLNamespace(Iterator iterator) { while (iterator.hasNext()) { OMElement omElemnt2 = (OMElement) iterator.next(); omElemnt2.setNamespace(xacmlContextNS); if (omElemnt2.getChildElements().hasNext()) { setXACMLNamespace(omElemnt2.getChildElements()); } } }
/** * Set relevant xacml namespace to all the children in the given iterator. * * @param iterator: Iterator for all children inside OMElement */ private static void setXACMLNamespace(Iterator iterator) { while (iterator.hasNext()) { OMElement omElemnt2 = (OMElement) iterator.next(); omElemnt2.setNamespace(xacmlContextNS); if (omElemnt2.getChildElements().hasNext()) { setXACMLNamespace(omElemnt2.getChildElements()); } } }
/** * Set relevant xacml namespace to all the children in the given iterator. * * * @param iterator: Iterator for all children inside OMElement */ private static void setXACMLNamespace(Iterator iterator) { while (iterator.hasNext()) { OMElement omElement2 = (OMElement) iterator.next(); omElement2.setNamespace(xacmlContextNS); if (omElement2.getChildElements().hasNext()) { setXACMLNamespace(omElement2.getChildElements()); } } }
public SOAPElement addChildElement(String localName, String prefix, String namespaceURI) throws SOAPException { if (prefix == null) { prefix = ""; } SOAPElementImpl<OMElement> childEle = (SOAPElementImpl<OMElement>)getOwnerDocument(). createElementNS(namespaceURI, prefix.length() == 0 ? localName : prefix + ":" + localName); childEle.omTarget.setNamespace(prefix.length() == 0 ? childEle.omTarget.declareDefaultNamespace(namespaceURI) : childEle.omTarget.declareNamespace(namespaceURI, prefix)); target.appendChild(childEle.target); childEle.setParentElement(this); return childEle; }
public SOAPElement addChildElement(String localName, String prefix, String namespaceURI) throws SOAPException { if (prefix == null) { prefix = ""; } SOAPElementImpl<OMElement> childEle = (SOAPElementImpl<OMElement>)getOwnerDocument(). createElementNS(namespaceURI, prefix.length() == 0 ? localName : prefix + ":" + localName); childEle.omTarget.setNamespace(prefix.length() == 0 ? childEle.omTarget.declareDefaultNamespace(namespaceURI) : childEle.omTarget.declareNamespace(namespaceURI, prefix)); target.appendChild(childEle.target); childEle.setParentElement(this); return childEle; }
protected void doWriteStartElement(String prefix, String localName, String namespaceURI) { // Get the OMNamespace object before we change the parent OMNamespace ns = getOMNamespace(prefix, namespaceURI, false); if (parent == null) { root.validateName(prefix, localName, namespaceURI); parent = root; } else { // We use the createOMElement variant that takes a OMXMLParserWrapper parameter and // don't pass the namespace. This avoids creation of a namespace declaration. parent = factory.createOMElement(localName, parent, null); } if (ns != null) { parent.setNamespace(ns, false); } }
protected void doWriteStartElement(String prefix, String localName, String namespaceURI) { // Get the OMNamespace object before we change the parent OMNamespace ns = getOMNamespace(prefix, namespaceURI, false); if (parent == null) { root.validateName(prefix, localName, namespaceURI); parent = root; } else { // We use the createOMElement variant that takes a OMXMLParserWrapper parameter and // don't pass the namespace. This avoids creation of a namespace declaration. parent = factory.createOMElement(localName, parent, null); } if (ns != null) { parent.setNamespace(ns, false); } }
void fix_v2_ns_recursive(OMElement ele, OMNamespace ns) { ele.setNamespace(ns); for (@SuppressWarnings("unchecked") Iterator<OMAttribute> it = ele.getAllAttributes(); it.hasNext();) { OMAttribute a = it.next(); if (a.getLocalName().equals("lang")) a.setOMNamespace(MetadataSupport.xml_namespace); } for (@SuppressWarnings("unchecked") Iterator<OMElement> it = ele.getChildElements(); it.hasNext();) { OMElement child = (OMElement) it.next(); fix_v2_ns_recursive(child, MetadataSupport.ebRIMns2); } }
public SOAPElement addChildElement(String localName, String prefix) throws SOAPException { String namespaceURI = getNamespaceURI(prefix); if (namespaceURI == null) { throw new SOAPException("Namespace not declared for the give prefix: " + prefix); } SOAPBodyElementImpl<OMElement> childEle = new SOAPBodyElementImpl<OMElement>( (OMElement)target.getOwnerDocument().createElementNS(namespaceURI, localName)); childEle.omTarget.setNamespace(childEle.omTarget.declareNamespace(namespaceURI, prefix)); target.appendChild(childEle.target); childEle.setParentElement(this); return childEle; }
public SOAPElement addChildElement(String localName, String prefix) throws SOAPException { String namespaceURI = getNamespaceURI(prefix); if (namespaceURI == null) { throw new SOAPException("Namespace not declared for the give prefix: " + prefix); } SOAPBodyElementImpl<OMElement> childEle = new SOAPBodyElementImpl<OMElement>( (OMElement)target.getOwnerDocument().createElementNS(namespaceURI, localName)); childEle.omTarget.setNamespace(childEle.omTarget.declareNamespace(namespaceURI, prefix)); target.appendChild(childEle.target); childEle.setParentElement(this); return childEle; }
/** * Format the sent in request as required by OpenSAML * * @param xacmlRequest : received XACML request * @return formatted request * @throws Exception */ private String formatRequest(String xacmlRequest) throws EntitlementProxyException { xacmlRequest = xacmlRequest.replace("\n", ""); OMElement omElemnt = null; try { omElemnt = org.apache.axiom.om.util.AXIOMUtil.stringToOM(xacmlRequest); omElemnt.setNamespace(xacmlContextNS); Iterator childIterator = omElemnt.getChildElements(); setXACMLNamespace(childIterator); return omElemnt.toString(); } catch (Exception e) { log.error("Error occurred while formatting the XACML request", e); throw new EntitlementProxyException("Error occurred while formatting the XACML request", e); } }