org.apache.axiom.om.OMNode.getNextOMSibling()方法的使用及代码示例

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

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

OMNode.getNextOMSibling介绍

[英]Returns the next sibling in document order.
[中]按文档顺序返回下一个同级。

代码示例

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

protected OMNode getNextNode(OMNode currentNode) {
    return currentNode.getNextOMSibling();
  }
}

代码示例来源:origin: stackoverflow.com

OMNode child = omElement.getFirstOMChild();
while ( child != null )
{
  if ( child instanceof OMText )
  {
    // process 'child' text here

    final OMNode nextSibling = child.getNextOMSibling();
    child.detach();    // detach from OM to keep memory usage low
    child = nextSibling;
  }
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-databinding-axiom

@Override
public boolean isTextOnly(OMElement element) throws XML2JavaMapperException {
  OMNode firstChild = element.getFirstOMChild();
  return firstChild instanceof OMText && firstChild.getNextOMSibling() == null;
}

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

OMElement getNextOMElementSibling(OMElement ele) {
  OMNode n = null;
  for (n = ele.getNextOMSibling(); n != null && !(n instanceof OMElement); n = n.getNextOMSibling())
    ;
  return (OMElement) n; 
}

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

OMElement findPeerWithName(OMElement ele, String name) {
  if (name == null)
    return null;
  
  OMNode focus = ele;
  
  while (focus != null) {
    if ((focus instanceof OMElement)) {
      OMElement focusEle = (OMElement) focus;
      if (focusEle.getLocalName().equals(name))
      return focusEle;
    }
    focus = focus.getNextOMSibling();
  }
  return null;
}

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

public Node getNextSibling() {
  if (next == null) {
    if (node.getParent() instanceof OMDocument) {
      OMNode n = node.getNextOMSibling();
      do {
        if (!(n instanceof OMText)) {
          next = fac.getNode(n);
          break;
        }
        n = n.getNextOMSibling();
      } while (true);
    } else {
      next = fac.getNode(node.getNextOMSibling());
    }
  }
  return next;
}

代码示例来源:origin: org.apache.abdera/abdera-parser

public <T extends Element> T getNextSibling() {
  OMNode el = this.getNextOMSibling();
  while (el != null) {
    if (el instanceof Element)
      return (T)getWrapped((Element)el);
    else
      el = el.getNextOMSibling();
  }
  return null;
}

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

public Node getFirstChild() {
  // an XML Document node should not give Text nodes as children.
  OMNode n = doc.getFirstOMChild();
  do {
    if (!(n instanceof OMText)){
      return fac.getNode(n);
    }
    n = n.getNextOMSibling();
  } while (true);
}

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

/**
 * @param node
 * @return next sibling or null
 */
private OMNode getNextSibling(OMNode node) {
  if (isOMSourcedElement(node)) {
    return node.getNextOMSibling();
  } else {
    return ((OMNodeEx) node).getNextOMSiblingIfAvailable();
  }
}

代码示例来源:origin: org.bluestemsoftware.open.eoa.ext/open-eoa-aspect-axiom

public String getTrimmedText() {
  String childText = null;
  OMNode child = this.getFirstOMChild();
  OMText textNode;
  while (child != null) {
    if (child.getType() == OMNode.TEXT_NODE) {
      textNode = (OMText) child;
      String textValue = textNode.getText();
      if (textValue != null &&
          !"".equals(textValue.trim())) {
        if (childText == null) childText = "";
        childText += textValue.trim();
      }
    }
    child = child.getNextOMSibling();
  }
  return childText;
}

代码示例来源:origin: org.bluestemsoftware.open.eoa.ext/open-eoa-aspect-axiom

/**
 * Returns the first Element node.
 *
 * @see org.apache.axiom.om.OMElement#getFirstElement()
 */
public OMElement getFirstElement() {
  OMNode node = getFirstOMChild();
  while (node != null) {
    if (node.getType() == Node.ELEMENT_NODE) {
      return (OMElement) node;
    } else {
      node = node.getNextOMSibling();
    }
  }
  return null;
}

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

public boolean hasNext() {
  if (!advance) {
    return current != null;
  }
  advance = false;
  OMNode sibling = current.getNextOMSibling();
  while (sibling != null) {
    if (sibling instanceof SOAPHeaderBlock) {
      SOAPHeaderBlock possible = (SOAPHeaderBlock) sibling;
      if (checkHeader(possible)) {
        current = (SOAPHeaderBlock) sibling;
        return true;
      }
    }
    sibling = sibling.getNextOMSibling();
  }
  current = null;
  return false;
}

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

public final void hasNumberOfChildren(int expected) {
    OMNode child = getSubject().getFirstOMChild();
    int actual = 0;
    while (child != null) {
      actual++;
      child = child.getNextOMSibling();
    }
    if (actual != expected) {
      failWithRawMessage("number of children is %s instead of %s", actual, expected);
    }
  }
}

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

/**
 * @param node
 * @return first child or null
 */
private OMNode _getFirstChild(OMContainer node) {
  if (isOMSourcedElement(node)) {
    OMNode first = node.getFirstOMChild();
    OMNode sibling = first;
    while (sibling != null) {
      sibling = sibling.getNextOMSibling();
    }
    return first;
  } else {
    return ((IContainer)node).getFirstOMChildIfAvailable();
  }
}

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

public void set(OMElement root) {
    String localname = root.getLocalName();

    if (requiresHome(localname))
      root.addAttribute("home", home, null);

    for (OMNode child=root.getFirstElement(); child != null; child=child.getNextOMSibling()) {
      if (child instanceof OMElement) {
        OMElement child_e = (OMElement) child;
        set(child_e);
      }
//            OMElement child_e = (OMElement) child;
//            set(child_e);
    }
  }

代码示例来源:origin: org.apache.abdera/abdera-parser

public void setText(String text) {
  complete();
  if (text != null) {
    OMNode child = this.getFirstOMChild();
    while (child != null) {
      if (child.getType() == OMNode.TEXT_NODE) {
        child.detach();
      }
      child = child.getNextOMSibling();
    }
    getOMFactory().createOMText(this, text);
  } else
    _removeAllChildren();
  // return (T)this;
}

代码示例来源:origin: org.apache.abdera/abdera-parser

public <T extends Element> T setText(Text.Type type, String value) {
  complete();
  init(type);
  if (value != null) {
    OMNode child = this.getFirstOMChild();
    while (child != null) {
      if (child.getType() == OMNode.TEXT_NODE) {
        child.detach();
      }
      child = child.getNextOMSibling();
    }
    getOMFactory().createOMText(this, value);
  } else
    _removeAllChildren();
  return (T)this;
}

代码示例来源:origin: org.apache.abdera/abdera-parser

public <T extends Element> T setText(Content.Type type, String value) {
  complete();
  init(type);
  if (value != null) {
    OMNode child = this.getFirstOMChild();
    while (child != null) {
      if (child.getType() == OMNode.TEXT_NODE) {
        child.detach();
      }
      child = child.getNextOMSibling();
    }
    getOMFactory().createOMText(this, value);
  } else
    _removeAllChildren();
  return (T)this;
}

代码示例来源:origin: wso2/wso2-synapse

public void testSynapse242() throws Exception {
  // create a new switch mediator
   XSLTMediator transformMediator = new XSLTMediator();
  // set XSLT transformation URL
  setXsltTransformationURL(transformMediator, "xslt-key");
   // invoke transformation, with static enveope
   MessageContext synCtx = new TestMessageContextBuilder().addFileEntry("xslt-key",
       "../../repository/conf/sample/resources/transform/transform_load_2.xml")
       .setBodyFromFile("../../repository/conf/sample/resources/transform/med_message.xml")
       .addTextAroundBody().setRequireAxis2MessageContext(true).build();
   transformMediator.mediate(synCtx);
   // validate result
   OMContainer body = synCtx.getEnvelope().getBody();
   assertTrue(body.getFirstOMChild().getNextOMSibling() instanceof OMElement);
   assertTrue(((OMElement) body.getFirstOMChild().getNextOMSibling()).getText().length() > 0);
}

代码示例来源:origin: wso2/wso2-synapse

public void testTransformXSLTCustomSource() throws Exception {
  // create a new XSLT mediator
  XSLTMediator transformMediator = new XSLTMediator();
  // set xpath condition to select source
  SynapseXPath xpath = new SynapseXPath("//m0:CheckPriceRequest");
  xpath.addNamespace("m0", "http://services.samples/xsd");
  transformMediator.setSource(xpath);
  // set XSLT transformation URL
  setXsltTransformationURL(transformMediator, "xslt-key");
  MessageContext synCtx = new TestMessageContextBuilder().setRequireAxis2MessageContext(true).addFileEntry
      ("xslt-key", "../../repository/conf/sample/resources/transform/transform_unittest.xslt")
      .setBodyFromString(SOURCE).addTextAroundBody().build();
  transformMediator.mediate(synCtx);
  // validate result
  assertQuoteElement(synCtx.getEnvelope().getBody().getFirstOMChild().getNextOMSibling());
}

相关文章