Java Code Examples for org.apache.axiom.om.OMElement#getAllAttributes()
The following examples show how to use
org.apache.axiom.om.OMElement#getAllAttributes() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XMLComparator.java From micro-integrator with Apache License 2.0 | 6 votes |
private static boolean compareAttributes(OMElement elementOne, OMElement elementTwo) { int elementOneAttribCount = 0; int elementTwoAttribCount = 0; Iterator attributes = elementOne.getAllAttributes(); while (attributes.hasNext()) { OMAttribute omAttribute = (OMAttribute) attributes.next(); OMAttribute attr = elementTwo.getAttribute(omAttribute.getQName()); if (attr == null) { return false; } elementOneAttribCount++; } Iterator elementTwoIter = elementTwo.getAllAttributes(); while (elementTwoIter.hasNext()) { elementTwoIter.next(); elementTwoAttribCount++; } return elementOneAttribCount == elementTwoAttribCount; }
Example 2
Source File: HttpRequestHashGenerator.java From micro-integrator with Apache License 2.0 | 6 votes |
/** * Gets the collection of attributes which are none namespace declarations for an OMElement sorted according to the * expanded names of the attributes. * * @param element - OMElement of which the none ns declaration attributes to be retrieved * @return the collection of attributes which are none namespace declarations */ public Collection getAttributesWithoutNS(OMElement element) { SortedMap map = new TreeMap(); Iterator itr = element.getAllAttributes(); while (itr.hasNext()) { OMAttribute attribute = (OMAttribute) itr.next(); if (!(attribute.getLocalName().equals("xmlns") || attribute.getLocalName().startsWith("xmlns:"))) { map.put(getExpandedName(attribute), attribute); } } return map.values(); }
Example 3
Source File: DOMHASHGenerator.java From micro-integrator with Apache License 2.0 | 6 votes |
/** * Gets the collection of attributes which are none namespace declarations for an OMElement sorted according to the * expanded names of the attributes. * * @param element - OMElement of which the none ns declaration attributes to be retrieved * @return the collection of attributes which are none namespace declarations */ public Collection getAttributesWithoutNS(OMElement element) { SortedMap map = new TreeMap(); Iterator itr = element.getAllAttributes(); while (itr.hasNext()) { OMAttribute attribute = (OMAttribute) itr.next(); if (!(attribute.getLocalName().equals("xmlns") || attribute.getLocalName().startsWith("xmlns:"))) { map.put(getExpandedName(attribute), attribute); } } return map.values(); }
Example 4
Source File: XMLComparator.java From product-ei with Apache License 2.0 | 6 votes |
private static boolean compareAttributes(OMElement elementOne, OMElement elementTwo) { int elementOneAttribCount = 0; int elementTwoAttribCount = 0; Iterator attributes = elementOne.getAllAttributes(); while (attributes.hasNext()) { OMAttribute omAttribute = (OMAttribute) attributes.next(); OMAttribute attr = elementTwo.getAttribute(omAttribute.getQName()); if (attr == null) { return false; } elementOneAttribCount++; } Iterator elementTwoIter = elementTwo.getAllAttributes(); while (elementTwoIter.hasNext()) { elementTwoIter.next(); elementTwoAttribCount++; } return elementOneAttribCount == elementTwoAttribCount; }
Example 5
Source File: Metadata.java From openxds with Apache License 2.0 | 6 votes |
OMElement dup_wrapper1(OMElement e) { OMElement e_dup = om_factory().createOMElement(e.getLocalName(), e.getNamespace()); for (Iterator it = e.getAllAttributes(); it.hasNext();) { OMAttribute a = (OMAttribute) it.next(); String name = a.getLocalName(); String value = a.getAttributeValue(); e_dup.addAttribute(name, value, null); } if (e.getLocalName().equals(wrapper.getLocalName())) { wrapperDup = e_dup; return e_dup; } for (Iterator it = e.getChildElements(); it.hasNext();) { OMElement ele = (OMElement) it.next(); OMElement ele_dup = dup_wrapper1(ele); e_dup.addChild(ele_dup); } return e_dup; }
Example 6
Source File: SoapTransportCommandProcessorTest.java From cougar with Apache License 2.0 | 6 votes |
private void assertAttributes(OMElement expectedElement, OMElement actualElement) { Iterator expectedIt = expectedElement.getAllAttributes(); Iterator actualIt = actualElement.getAllAttributes(); while (expectedIt.hasNext()) { assertTrue(actualIt.hasNext()); OMAttribute expectedAttribute = (OMAttribute)expectedIt.next(); OMAttribute actualAttribute = (OMAttribute)actualIt.next(); assertEquals(expectedAttribute.getAttributeType(), actualAttribute.getAttributeType()); assertEquals(expectedAttribute.getAttributeValue(), actualAttribute.getAttributeValue()); if (expectedAttribute.getNamespace() == null) { assertNull(actualAttribute.getNamespace()); } else { assertEquals(expectedAttribute.getNamespace().getNamespaceURI(), actualAttribute.getNamespace().getNamespaceURI()); } } assertFalse(actualIt.hasNext()); }
Example 7
Source File: Metadata.java From openxds with Apache License 2.0 | 5 votes |
void fix_v2_ns_recursive(OMElement ele, OMNamespace ns) { ele.setNamespace(ns); for (Iterator it = ele.getAllAttributes(); it.hasNext();) { OMAttribute a = (OMAttribute) it.next(); if (a.getLocalName().equals("lang")) a.setOMNamespace(MetadataSupport.xml_namespace); } for (Iterator it = ele.getChildElements(); it.hasNext();) { OMElement child = (OMElement) it.next(); fix_v2_ns_recursive(child, MetadataSupport.ebRIMns2); } }
Example 8
Source File: RegistryErrorList.java From openxds with Apache License 2.0 | 5 votes |
HashMap<String, String> getErrorDetails(OMElement registryError) { HashMap<String, String> err = new HashMap<String, String>(); for (Iterator<OMAttribute> it=registryError.getAllAttributes(); it.hasNext(); ) { OMAttribute att = it.next(); String name = att.getLocalName(); String value = att.getAttributeValue(); err.put(name, value); } return err; }
Example 9
Source File: TranslateToV2.java From openxds with Apache License 2.0 | 5 votes |
protected void copy_attributes(OMElement from, OMElement to) { String element_name = from.getLocalName(); for (Iterator it=from.getAllAttributes(); it.hasNext(); ) { OMAttribute from_a = (OMAttribute) it.next(); String name = from_a.getLocalName(); String value = from_a.getAttributeValue(); OMNamespace xml_namespace = MetadataSupport.xml_namespace; OMNamespace namespace = null; if (name.endsWith("status")) value = translate_att(value); else if (name.endsWith("associationType")) value = translate_att(value); else if (name.equals("minorVersion")) continue; else if (name.equals("majorVersion")) continue; else if (name.equals("lang")) namespace = xml_namespace; else if (name.equals("objectType") && value.startsWith("urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:")) { String[] parts = value.split(":"); value = parts[parts.length-1]; } // else if (name.equals("objectType") && ! value.startsWith("urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:")) // value = "urn:oasis:names:tc:ebxml-regrep:ObjectType:RegistryObject:" + value; OMAttribute to_a = MetadataSupport.om_factory.createOMAttribute(name, namespace, value); to.addAttribute(to_a); } }