gpt4 book ai didi

org.xmlpull.v1.builder.XmlElement类的使用及代码示例

转载 作者:知者 更新时间:2024-03-25 21:09:05 27 4
gpt4 key购买 nike

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

XmlElement介绍

[英]Represents Element Information Item except for in-scope namespaces that can be reconstructed by visiting this element parent, checking its namespaces, then grandparent and so on. For convenience there are methods to resolve namespace prefix for given namespace name.
NOTE: this representaiton is optimized for streaming - iterator approach that allows gradual visiting of nodes is preferred over indexed access.
[中]表示Element Information Item,但作用域内的命名空间除外,可以通过访问此元素的父元素、检查其命名空间、然后检查其祖父母等来重建该命名空间。为了方便起见,有一些方法可以解析给定名称空间名称的名称空间前缀。
注:此表示为流式优化——与索引访问相比,允许节点逐步访问的迭代器方法更可取。

代码示例

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

public Iterator children() {
  return target.children();
}

代码示例来源:origin: org.ogce/xpp3

public String getElementQName(Object obj)
{
  XmlElement elem = (XmlElement) obj;
  String prefix = null;
  if(elem.getNamespace() != null) {
    //TODO REVISIT: needs to declare prefix if namesapce name != null ... or not?
    prefix = elem.getNamespace().getPrefix();
  }
  if ( prefix == null || "".equals( prefix ) )
  {
    return elem.getName();
  }
  return prefix + ":" + elem.getName();
}

代码示例来源:origin: org.ogce/xpp3

public Iterator getAttributeAxisIterator(Object contextNode)
{
  if ( ! ( contextNode instanceof XmlElement ) )
  {
    return null;
  }
  XmlElement elem = (XmlElement) contextNode;
  return elem.attributes();
}

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

public void serializeStartTag(XmlElement el, XmlSerializer ser) {
  try {
    XmlNamespace elNamespace = el.getNamespace();
    String elPrefix = (elNamespace != null) ? elNamespace.getPrefix() : "";
    if(elPrefix == null) {
    if(el.hasNamespaceDeclarations()) {
      Iterator iter = el.namespaces();
      while (iter.hasNext())
    ser.startTag(el.getNamespaceName(), el.getName());
    if(el.hasAttributes()) {
      Iterator iter = el.attributes();
      while (iter.hasNext())

代码示例来源:origin: org.apache.airavata/common-utils

Element domElement = document.createElement(xppElement.getName());
Iterator nsIt = xppElement.namespaces();
while (nsIt.hasNext()) {
  org.xmlpull.v1.builder.XmlNamespace namespace = (org.xmlpull.v1.builder.XmlNamespace) nsIt.next();
Iterator attrIt = xppElement.attributes();
while (attrIt.hasNext()) {
  org.xmlpull.v1.builder.XmlAttribute attribute = (org.xmlpull.v1.builder.XmlAttribute) attrIt.next();
Iterator elementIt = xppElement.children();
while (elementIt.hasNext()) {
  Object object = elementIt.next();

代码示例来源:origin: org.ogce/xpp3

public String getElementName(Object obj)
{
  XmlElement elem = (XmlElement) obj;
  return elem.getName();
}

代码示例来源:origin: org.ogce/xpp3

private void setTarget(XmlElement target) {
  this.target = target;
  if(target.getParent() != null) {
    //
    //throw new XmlBuilderException("element to wrap must have no parent to be wrapped");
    //XmlContainer parent = target.getParent();
    parent = target.getParent();
    if(parent instanceof XmlDocument) {
      XmlDocument doc = (XmlDocument) parent;
      doc.setDocumentElement(this);
    } if(parent instanceof XmlElement) {
      XmlElement parentEl = (XmlElement) parent;
      parentEl.replaceChild(this, target);
    }
  }
  // new "wrapping" parent replaces old parent for children
  Iterator iter = target.children();
  while (iter.hasNext())
  {
    Object child = iter.next();
    fixImportedChildParent(child);
  }
  //target.setParent(null);
  //IdentityHashMap id = nul;
}

代码示例来源:origin: org.ogce/xpp3

XmlNamespace ns = current.getNamespace();
Iterator declaredNamespaces = current.namespaces();
if(current.getParent() instanceof XmlElement) {
  current = (XmlElement) current.getParent();
} else {
  current = null;

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

if(eventType == XmlPullParser.START_TAG) {
  XmlElement child = parseStartTag(pp);
  curElem.addElement(child);
  curElem = child;
} else if(eventType == XmlPullParser.END_TAG) {
  XmlContainer parent = curElem.getParent();
  if(parent == null) {
    if(pp.getDepth() != depth) {
  curElem.addChild(pp.getText());

代码示例来源:origin: org.apache.airavata/airavata-workflow-engine

XmlElement valueElement = outputElement.element(null, name);
Iterator childIt = valueElement.children();
int numberOfChildren = 0;
while (childIt.hasNext()) {
  Object child = valueElement.children().next();
  if (child instanceof String) {
    Object child1 = ((XmlElement) child).children().next();
    if (child1 instanceof String) {

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

public void serializeEndTag(XmlElement el, XmlSerializer ser) {
  try {
    ser.endTag(el.getNamespaceName(), el.getName());
  } catch (IOException e) {
    throw new XmlBuilderException("serializing XML end tag failed", e);
  }
}

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

private void serializeFragment(XmlElement el, XmlSerializer ser)
  {
    serializeStartTag(el, ser);
    //try {
    if(el.hasChildren()) {
      Iterator iter = el.children();
      while (iter.hasNext())
      {
        Object child = iter.next();
        if(child instanceof XmlSerializable) {
          //((XmlSerializable)child).serialize(ser);
          try {
            ((XmlSerializable)child).serialize(ser);
          } catch (IOException e) {
            throw new XmlBuilderException("could not serialize item "+child+": "+e, e);
          }
          
        } else if(child instanceof XmlElement) {
          serializeFragment((XmlElement)child, ser);
        } else {
          serializeItem(child, ser);
        }
      }
    }
    //} catch (IOException e) {
    //    throw new XmlBuilderException("serializing XML element children failed", e);
    //}
    serializeEndTag(el, ser);
  }
}

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

public XmlElement addElement(XmlElement child)
{
  return fixElementParent( target.addElement(child) );
}

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

public XmlElement element(int position) {
  return target.element(position);
}

代码示例来源:origin: org.apache.airavata/airavata-xbaya-gui

private static ArrayList<String> findArrayValue(String name, WSIFMessageElement response) {
    XmlElement param = response.element(null, name);
    if (param != null) {
      Iterable it = param.elements(null, "value");
      if (it != null) {
        ArrayList<String> values = new ArrayList<String>();

        Iterator arrayValues = it.iterator();
        while (arrayValues.hasNext()) {
          values.add(((XmlElement) arrayValues.next()).requiredTextContent());
        }
        return values;
      }
    }
    return null;
  }
}

代码示例来源:origin: org.apache.airavata/airavata-workflow-engine

XmlElement paramsElem = builder.newFragment(this.requestNS, paramName);
if (value instanceof String) {
  paramsElem.addChild(value);
} else if (value instanceof Collection) {
  Collection list = (Collection) value;
  while (arrayValues.hasNext()) {
    XmlElement item = builder.newFragment("value");
    item.addChild(arrayValues.next());
    paramsElem.addChild(item);
  while (arrayValues.hasNext()) {
    XmlElement item = builder.newFragment("value");
    item.addChild(arrayValues.next());
    paramsElem.addChild(item);
  for (int i = 0; i < list.length; i++) {
    XmlElement item = builder.newFragment("value");
    item.addChild(list[i]);
    paramsElem.addChild(item);
inputMsgElem.addElement(paramsElem);

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

public void addChild(Object child) {
  target.addChild(child);
  fixImportedChildParent(child);
}

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

public void setName(String name) {
  target.setName(name);
}

代码示例来源:origin: org.ogce/xpp3

public Iterator namespaces() {
  return target.namespaces();
}

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

public String requiredTextContent() {
  return target.requiredTextContent();
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com