Refine search
protected String getAttribute(OMElement elt, QName qName) { OMAttribute a = elt.getAttribute(qName); if (a != null) { return a.getAttributeValue(); } return null; }
private Boolean getBoolean(OMElement items) { for (Iterator<OMAttribute> iAttr = items.getAllAttributes(); iAttr.hasNext();) { OMAttribute test = iAttr.next(); String localName = test.getLocalName(); if (localName.equals("nil")) { if (test.getAttributeValue().equals("true")) { return null; } else if (test.getAttributeValue().equals("false")) { return false; } } else { return Boolean.parseBoolean(items.getText()); } } return false; } }
@Override public Map<QName,String> getAttributes() { Map<QName,String> attributes = null; for (Iterator it = ((OMElement)node).getAllAttributes(); it.hasNext(); ) { OMAttribute attr = (OMAttribute)it.next(); if (attributes == null) { attributes = new HashMap<QName,String>(); } attributes.put(attr.getQName(), attr.getAttributeValue()); } return attributes; }
/** * Construct an XPath expression from a given attribute. * The string representation of the expression is taken from the attribute * value, while the attribute's owner element is used to determine the * namespace context of the expression. * * @param attribute the attribute to construct the expression from * @throws JaxenException if there is a syntax error while parsing the expression * or if the namespace context could not be set up */ public AXIOMXPath(OMAttribute attribute) throws JaxenException { this(attribute.getOwner(), attribute.getAttributeValue()); }
private static void writeAttribute( XMLStreamWriter writer, OMAttribute attrib ) throws XMLStreamException { writer.writeAttribute( attrib.getNamespace().getNamespaceURI(), attrib.getAttributeValue() ); }
/** * Retrieves the QName of the given attribute node. * * @param object the context attribute node * @return Returns the qualified name of the attribute node. */ public String getAttributeQName(Object object) { OMAttribute attr = (OMAttribute) object; String prefix = attr.getNamespace().getPrefix(); if (prefix == null || "".equals(prefix)) { return attr.getLocalName(); } return prefix + ":" + attr.getLocalName(); }
private void replaceElement(TemplateEndpoint templateEndpoint, OMElement element) { Iterator attributesItr = element.getAllAttributes(); while (attributesItr.hasNext()) { OMAttribute attribute = (OMAttribute) attributesItr.next(); String replace = replace(attribute.getAttributeValue(), templateEndpoint); if (replace != null) { attribute.setAttributeValue(replace); } } if (element.getText() != null && !"".equals(element.getText())) { String replace = replace(element.getText(), templateEndpoint); if (replace != null) { element.setText(replace); } } Iterator elemItr = element.getChildElements(); while (elemItr.hasNext()) { OMElement childElement = (OMElement) elemItr.next(); replaceElement(templateEndpoint, childElement); } }
private void readallChildElements() { Iterator childs = parent.getChildElements(); while (childs.hasNext()) { OMElement omElement = (OMElement)childs.next(); OMAttribute id = omElement.getAttribute(new QName("id")); if (id != null) { childs.remove(); elementMap.put(id.getAttributeValue(), omElement); } } filledTable = true; }
@SuppressWarnings("unchecked") private List<Validator> getValidators(Iterator<OMElement> valItr) { List<Validator> vals = new ArrayList<Validator>(); OMElement valEl; String valElementName; Iterator<OMAttribute> attrItr; Map<String, String> propMap; OMAttribute attr; while (valItr.hasNext()) { valEl = valItr.next(); valElementName = valEl.getLocalName(); attrItr = valEl.getAllAttributes(); propMap = new HashMap<String, String>(); while (attrItr.hasNext()) { attr = attrItr.next(); propMap.put(attr.getLocalName(), attr.getAttributeValue()); } Map<String, String> customPropMap = extractAdvancedProps(valEl); vals.add(new Validator(valElementName, propMap, customPropMap)); } return vals; }
private void addParam(String dsname, String className) throws JaxenException { AXIOMXPath xpathExpression = new AXIOMXPath("//a:parameter"); xpathExpression.addNamespace("a", "http://jasperreports.sourceforge.net/jasperreports"); OMElement documentElement = document.getOMDocumentElement(); List nodeList = xpathExpression.selectNodes(documentElement); OMElement element = (OMElement) nodeList.get(0); OMElement newParam = element.cloneOMElement(); newParam.getAttribute(new QName("name")).setAttributeValue(dsname); newParam.getAttribute(new QName("class")).setAttributeValue(className); documentElement.addChild(newParam); }
public void setLocationPrefix(String prefix) { OMElement ele = registryErrorList(); for (OMElement e : XmlUtil.decendentsWithLocalName(ele, "RegistryError")) { OMAttribute at = e.getAttribute(MetadataSupport.location_qname); if (at == null) { at = MetadataSupport.om_factory.createOMAttribute("location", null, ""); e.addAttribute(at); } at.setAttributeValue(prefix + at.getAttributeValue()); } }
/** * 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())); } } }
/** * Retrieves the string-value of an attribute node. This should be the XML 1.0 normalized * attribute value. This may be the empty string but must not be null. * * @param object the attribute node * @return Returns the string-value of the node. */ public String getAttributeStringValue(Object object) { return ((OMAttribute) object).getAttributeValue(); }
public static SynapseXPath getSynapseXPath(OMElement elem, QName attribName) throws JaxenException { SynapseXPath xpath = null; OMAttribute xpathAttrib = elem.getAttribute(attribName); if (xpathAttrib != null && xpathAttrib.getAttributeValue() != null) { xpath = new SynapseXPath(xpathAttrib.getAttributeValue()); OMElementUtils.addNameSpaces(xpath, elem, log); } else { handleException("Couldn't find the XPath attribute with the QName : " + attribName.toString() + " in the element : " + elem.toString()); } return xpath; }
private void updateFontAttributes(OMElement fontElement, FontStyleDTO style) { fontElement.getAttribute(new QName("fontName")). setAttributeValue(style.getFontName()); fontElement.getAttribute(new QName("size")). setAttributeValue(String.valueOf(style.getFontSize())); fontElement.getAttribute(new QName("isBold")). setAttributeValue(String.valueOf(style.isBold())); fontElement.getAttribute(new QName("isItalic")). setAttributeValue(String.valueOf(style.isItalic())); fontElement.getAttribute(new QName("isUnderline")). setAttributeValue(String.valueOf(style.isUnderLine())); fontElement.getAttribute(new QName("isStrikeThrough")). setAttributeValue(String.valueOf(style.isStrikeThough())); }
private static OMElement updateWSDLImports(OMElement omElement,boolean isMasterArtifact) throws JaxenException { AXIOMXPath xPath = new AXIOMXPath("//wsd:import[@location]"); xPath.addNamespace("wsd", "http://schemas.xmlsoap.org/wsdl/"); Object result = xPath.evaluate(omElement); if(!(result instanceof ArrayList)){ return omElement; } List list = (ArrayList) result; for (Object obj : list) { OMElement _import = (OMElement) obj; OMAttribute attribute = _import.getAttribute(new QName("location")); String newValue = isMasterArtifact ? "dependencies" + attribute.getAttributeValue().substring(attribute.getAttributeValue().lastIndexOf("/")) :attribute.getAttributeValue().substring(attribute.getAttributeValue().lastIndexOf("/")+1); attribute.setAttributeValue(newValue); } return omElement; }
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); } }
void updateClassification(OMElement classification, Code code) { classification.getAttribute(nodeRepresentationQName).setAttributeValue(code.getCode()); OMElement codeSystemElement = codeSystemElement(classification); if (codeSystemElement != null) codeSystemElement.setText(code.getScheme()); updateDisplayName(classification, code.getDisplay()); }
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; }
public Map<QName, String> getAttributes(OMElement s) { Map<QName, String> mp = new HashMap<QName, String>(); Iterator<?> it = s.getAllAttributes(); while (it.hasNext()) { OMAttribute attr = (OMAttribute)it.next(); if (attr.getNamespace() == null) { mp.put(new QName("", attr.getLocalName()), attr.getAttributeValue()); } else { mp.put(new QName(attr.getNamespace().getNamespaceURI(), attr.getLocalName()), attr.getAttributeValue()); } } return mp; }