org.apache.axiom.om.OMAttribute类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(10.6k)|赞(0)|评价(0)|浏览(119)

本文整理了Java中org.apache.axiom.om.OMAttribute类的一些代码示例,展示了OMAttribute类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OMAttribute类的具体详情如下:
包路径:org.apache.axiom.om.OMAttribute
类名称:OMAttribute

OMAttribute介绍

[英]Interface OMAttribute
[中]接口属性

代码示例

代码示例来源:origin: org.apache.synapse/synapse-core

protected String getAttribute(OMElement elt, QName qName) {
  OMAttribute a = elt.getAttribute(qName);
  if (a != null) {
    return a.getAttributeValue();
  }
  return null;
}

代码示例来源:origin: magja/magja

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;
 }
}

代码示例来源:origin: org.apache.ws.commons.axiom/axiom-truth

@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;
}

代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api

/**
 * 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());
}

代码示例来源:origin: deegree/deegree3

private static void writeAttribute( XMLStreamWriter writer, OMAttribute attrib )
            throws XMLStreamException {
  writer.writeAttribute( attrib.getNamespace().getNamespaceURI(), attrib.getAttributeValue() );
}

代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api

/**
 * 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();
}

代码示例来源:origin: org.apache.synapse/synapse-core

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);
  }
}

代码示例来源:origin: org.apache.axis2/axis2-adb

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;
}

代码示例来源:origin: org.wso2.carbon.data/org.wso2.carbon.dataservices.ui

@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;
}

代码示例来源:origin: org.wso2.carbon.commons/org.wso2.carbon.reporting.template.core

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);
}

代码示例来源:origin: usnistgov/iheos-toolkit2

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());
  }
}

代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api

/**
   * 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()));
    }
  }
}

代码示例来源:origin: org.apache.ws.commons.axiom/axiom-api

/**
 * 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();
}

代码示例来源:origin: org.apache.synapse/synapse-core

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;
}

代码示例来源:origin: org.wso2.carbon.commons/org.wso2.carbon.reporting.template.core

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()));
}

代码示例来源:origin: org.wso2.carbon.registry/org.wso2.carbon.registry.resource

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;
}

代码示例来源:origin: usnistgov/iheos-toolkit2

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);
  }
}

代码示例来源:origin: usnistgov/iheos-toolkit2

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());
}

代码示例来源:origin: usnistgov/iheos-toolkit2

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;
}

代码示例来源:origin: org.apache.neethi/neethi

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;
}

相关文章