Examples of OMNode


Examples of org.apache.axiom.om.OMNode

    OMElement element = this.getFirstChildWithName(qname);
    if (element != null && value != null) {
      element.setText(value);
    } else if (element != null && value == null) {
      for (Iterator i = element.getChildren(); i.hasNext();) {
        OMNode node = (OMNode) i.next();
        node.discard();
      }
    } else if (element == null && value != null ) {
      element = factory.createOMElement(qname, this);
      element.setText(value);
      this.addChild(element);
View Full Code Here

Examples of org.apache.axiom.om.OMNode

    }
  }
 
  protected void _removeAllChildren() {
    for (Iterator i = getChildren(); i.hasNext();) {
      OMNode node = (OMNode) i.next();
      node.discard();
    }
  }
View Full Code Here

Examples of org.apache.axiom.om.OMNode

        attr.getAttributeValue(),
        (attr.getNamespace() != null) ?
          dest.declareNamespace(attr.getNamespace()) : null);
    }
    for (Iterator i = src.getChildren(); i.hasNext();) {
      OMNode node = (OMNode) i.next();
      if (node.getType() == OMNode.ELEMENT_NODE) {
        OMElement element = (OMElement) node;
        OMElement child = _create(element);
        if (child != null) {
          _copyElement(element, child);
          dest.addChild(child);
        }
      } else if (node.getType() == OMNode.CDATA_SECTION_NODE) {
        OMText text = (OMText) node;
        factory.createOMText(dest,text.getText(), OMNode.CDATA_SECTION_NODE);
      } else if (node.getType() == OMNode.TEXT_NODE) {
        OMText text = (OMText) node;
        factory.createOMText(dest,text.getText());
      } else if (node.getType() == OMNode.COMMENT_NODE) {
        OMComment comment = (OMComment) node;
        factory.createOMComment(dest, comment.getValue());
      } else if (node.getType() == OMNode.PI_NODE) {
        OMProcessingInstruction pi = (OMProcessingInstruction) node;
        factory.createOMProcessingInstruction(dest, pi.getTarget(), pi.getValue());
      } else if (node.getType() == OMNode.SPACE_NODE) {
        OMText text = (OMText) node;
        factory.createOMText(dest, text.getText(), OMNode.SPACE_NODE);
      } else if (node.getType() == OMNode.ENTITY_REFERENCE_NODE) {
        OMText text = (OMText) node;
        factory.createOMText(dest, text.getText(), OMNode.ENTITY_REFERENCE_NODE);
      }
    }
    return dest;
View Full Code Here

Examples of org.apache.axiom.om.OMNode

          try {
            String value = StringFunction.evaluate(o, navigator);
            IRI resolved = null;
            IRI baseUri = null;
            if (o instanceof OMNode) {
              OMNode node = (OMNode) o;
              OMContainer el = node.getParent();
              if (el instanceof Document) {
                Document doc = (Document) el;
                baseUri = doc.getBaseUri();
              } else if (el instanceof Element) {
                Element element = (Element) el;
View Full Code Here

Examples of org.apache.axiom.om.OMNode

        level = includeSelf ? 0 : 1;
    }

    protected OMSerializable getNextNode(OMSerializable currentNode) {
        if (currentNode instanceof OMContainer) {
            OMNode firstChild = ((OMContainer)currentNode).getFirstOMChild();
            if (firstChild != null) {
                level++;
                return firstChild;
            }
        }
        OMSerializable node = currentNode;
        while (true) {
            if (level == 0) {
                return null;
            }
            OMNode nextSibling = ((OMNode)node).getNextOMSibling();
            if (nextSibling != null) {
                return nextSibling;
            } else {
                node = ((OMNode)node).getParent();
                level--;
View Full Code Here

Examples of org.apache.axiom.om.OMNode

    }
   
    public static String getText(OMElement element) {
        String childText = null;
        StringBuffer buffer = null;
        OMNode child = element.getFirstOMChild();

        while (child != null) {
            final int type = child.getType();
            if (type == OMNode.TEXT_NODE || type == OMNode.CDATA_SECTION_NODE) {
                OMText textNode = (OMText) child;
                String textValue = textNode.getText();
                if (textValue != null && textValue.length() != 0) {
                    if (childText == null) {
                        // This is the first non empty text node. Just save the string.
                        childText = textValue;
                    } else {
                        // We've already seen a non empty text node before. Concatenate using
                        // a StringBuffer.
                        if (buffer == null) {
                            // This is the first text node we need to append. Initialize the
                            // StringBuffer.
                            buffer = new StringBuffer(childText);
                        }
                        buffer.append(textValue);
                    }
                }
            }
            child = child.getNextOMSibling();
        }

        if (childText == null) {
            // We didn't see any text nodes. Return an empty string.
            return "";
View Full Code Here

Examples of org.apache.axiom.om.OMNode

   
    public static Reader getTextAsStream(OMElement element, boolean cache) {
        // If the element is not an OMSourcedElement and has not more than one child, then the most
        // efficient way to get the Reader is to build a StringReader
        if (!(element instanceof OMSourcedElement) && (!cache || element.isComplete())) {
            OMNode child = element.getFirstOMChild();
            if (child == null) {
                return new StringReader("");
            } else if (child.getNextOMSibling() == null) {
                return new StringReader(child instanceof OMText ? ((OMText)child).getText() : "");
            }
        }
        // In all other cases, extract the data from the XMLStreamReader
        try {
View Full Code Here

Examples of org.apache.axiom.om.OMNode

public final class OMNodeHelper {
    private OMNodeHelper() {}
   
    public static OMNode getNextOMSibling(IChildNode node) throws OMException {
        OMNode nextSibling = node.getNextOMSiblingIfAvailable();
        if (nextSibling == null) {
            IParentNode parent = node.getIParentNode();
            if (parent != null && parent.getBuilder() != null) {
                switch (parent.getState()) {
                    case IParentNode.DISCARDED:
View Full Code Here

Examples of org.apache.axiom.om.OMNode

                // parsed yet.  We can't use getBody() yet...it will
                // cause a failure.  So instead, carefully find the
                // body and insert the header.  If the body is not found,
                // this indicates that it has not been parsed yet...and
                // the code will fall through to the super.addChild.
                OMNode node = this.lastChild;
                while (node != null) {
                    if (node instanceof SOAPBody) {
                        node.insertSiblingBefore(child);
                        return;
                    }
                    node = node.getPreviousOMSibling();
                }
            }
        }
        super.addChild(child, fromBuilder);       
    }
View Full Code Here

Examples of org.apache.axiom.om.OMNode

        OMElement element = getFirstElement();
        if (element != null) {
            if (SOAPConstants.BODY_LOCAL_NAME.equals(element.getLocalName())) {
                return (SOAPBody) element;
            } else {      // if not second element SHOULD be the body
                OMNode node = element.getNextOMSibling();
                while (node != null && node.getType() != OMNode.ELEMENT_NODE) {
                    node = node.getNextOMSibling();
                }
                if (node == null) {
                    // The envelope only contains a header
                    return null;
                } else if (SOAPConstants.BODY_LOCAL_NAME.equals(((OMElement)node).getLocalName())) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.