public Factory getFactory() { return (Factory)attr.getOMFactory(); }
private static void removeNamespaces(OMElement element, boolean processAttrbs) { OMNamespace ns = element.getNamespace(); Iterator i = element.getAllDeclaredNamespaces(); while (i.hasNext()) { i.next(); i.remove(); } String prefix; if (ns != null) { prefix = "";//element.getNamespace().getPrefix(); element.setNamespace(element.getOMFactory().createOMNamespace("", prefix)); } Iterator children = element.getChildElements(); while (children.hasNext()) { removeNamespaces((OMElement) children.next(), processAttrbs); } if (!processAttrbs) { return; } Iterator attrbs = element.getAllAttributes(); while (attrbs.hasNext()) { OMAttribute attrb = (OMAttribute) attrbs.next(); prefix = "";//attrb.getQName().getPrefix(); attrb.setOMNamespace(attrb.getOMFactory().createOMNamespace("", prefix)); //element.removeAttribute(attrb); } }
/** * In Axiom, a single tree should always contain objects created from the same type of factory * (eg: LinkedListImplFactory, DOMFactory, etc.,). This method will convert omAttribute to the * given omFactory. * * @see ElementHelper#importOMElement(OMElement, OMFactory) to convert instances of OMElement */ public static void importOMAttribute(OMAttribute omAttribute, OMElement omElement) { // first check whether the given OMAttribute has the same OMFactory if (omAttribute.getOMFactory().getMetaFactory() == omElement.getOMFactory().getMetaFactory()) { omElement.addAttribute(omAttribute); } else { OMNamespace ns = omAttribute.getNamespace(); omElement.addAttribute(omAttribute.getLocalName(), omAttribute.getAttributeValue(), omElement.getOMFactory().createOMNamespace(ns.getNamespaceURI(), ns.getPrefix())); } } }