/** * Replace a node with another one. * * @param oldNode * old node * @param newNode * new node * @return the old node that is detached */ public static OMNode replaceNode(OMNode oldNode, OMNode newNode) { oldNode.insertSiblingAfter(newNode); return oldNode.detach(); }
protected OMNode getNextNode(OMNode currentNode) { return currentNode.getNextOMSibling(); } }
public List getAllSoapTexts() { List faultTexts = new ArrayList(1); Iterator childrenIter = this.getChildren(); while (childrenIter.hasNext()) { OMNode node = (OMNode) childrenIter.next(); if (node.getType() == OMNode.ELEMENT_NODE && (node instanceof SOAPFaultText)) { faultTexts.add(((SOAPFaultText) node)); } } return faultTexts; }
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; } }
/** * 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; }
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; }
static void processExpressions(ITag tag, IParserContext context) { if (!(tag instanceof ExpressionTag)) { // make sure all text nodes are converted to <expression> tags OMElement ele = context.getElement(); for (OMNode child : AxiomUtils.getNodes(ele)) { if (child.getType() == OMNode.TEXT_NODE) { OMText textNode = (OMText) child; String text = textNode.getText(); if (StringUtils.isNotBlank(text)) { OMElement expTag = createExpressionTag(text, ele.getLineNumber()); child.insertSiblingAfter(expTag); child.detach(); } } } } }
public final void detachNode() { omTarget.detach(); }
if (resultValue instanceof String) { OMAbstractFactory.getOMFactory().createOMText( ((OMNode) o).getParent(), (String) resultValue); ((OMNode) o).detach(); } else if (resultValue instanceof OMNode) { ((OMNode) o).insertSiblingAfter((OMNode) resultValue); ((OMNode) o).detach();
/** * Constructor. * * @param root * the root node of the object model subtree that is being serialized; this * information is used by the serializer in scenarios that require access to the * namespace context of the parent of the root node * @param namespaceRepairing * indicates if the serializer should perform namespace repairing * @param preserveNamespaceContext * indicates if the namespace context determined by the ancestors of the root node * should be strictly preserved in the output */ public Serializer(OMSerializable root, boolean namespaceRepairing, boolean preserveNamespaceContext) { this.root = root; if (root instanceof OMNode) { OMContainer parent = ((OMNode)root).getParent(); if (parent instanceof OMElement) { contextElement = (OMElement)parent; } else { contextElement = null; } } else { contextElement = null; } this.namespaceRepairing = namespaceRepairing; this.preserveNamespaceContext = preserveNamespaceContext; }
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; }
Object o = expression.evaluate(envelope, synCtx); if (o instanceof OMNode) { resultContainer.setParent(((OMNode) o).getParent()); elementList.add(((OMNode) o).detach()); } else if (o instanceof List) { List oList = (List) o; if (oList.size() > 0) { resultContainer.setParent((((OMNode) oList.get(0)).getParent())); elementList.add(((OMNode) elem).detach());
public Node getPreviousSibling() { if (prev == null) { if (node.getParent() instanceof OMDocument) { OMNode n = node.getPreviousOMSibling(); do { if (!(n instanceof OMText)) { prev = fac.getNode(n); break; } n = n.getPreviousOMSibling(); } while (true); } else { prev = fac.getNode(node.getPreviousOMSibling()); } } return prev; }
public SOAPElement addTextNode(String text) throws SOAPException { Node firstChild = target.getFirstChild(); if (firstChild instanceof org.w3c.dom.Text) { ((org.w3c.dom.Text)firstChild).setData(text); } else { // Else this is a header ((OMNode)firstChild).insertSiblingBefore(this.omTarget.getOMFactory().createOMText(text)); } return this; }
/** * {@inheritDoc} */ @Override public void build() { this.omNode.build(); }
while (node != null) { if (node instanceof SOAPBody) { node.insertSiblingBefore(child); return; node = node.getPreviousOMSibling();
om.detach(); prevSib.insertSiblingAfter( newEl );
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; }
static void processExpressions(ITag tag, IParserContext context) { if (!(tag instanceof ExpressionTag)) { // make sure all text nodes are converted to <expression> tags OMElement ele = context.getElement(); for (OMNode child : AxiomUtils.getNodes(ele)) { if (child.getType() == OMNode.TEXT_NODE) { OMText textNode = (OMText) child; String text = textNode.getText(); if (StringUtils.isNotBlank(text)) { OMElement expTag = createExpressionTag(text, ele.getLineNumber()); child.insertSiblingAfter(expTag); child.detach(); } } } } }
public final void detachNode() { omTarget.detach(); }