/** * {@inheritDoc} */ @Override public BXML<?> descendants(String qname) { List<BXML<?>> descendants = new ArrayList<BXML<?>>(); switch (nodeType) { case ELEMENT: addDescendants(descendants, (OMElement) omNode, getQname(qname).toString()); break; default: break; } return new BXMLSequence(new BValueArray(descendants.toArray(new BXML[descendants.size()]), BTypes.typeXML)); }
/** * {@inheritDoc} */ @Override public BXML<?> elements(String qname) { BValueArray elementsSeq = new BValueArray(); switch (nodeType) { case ELEMENT: if (getElementName().stringValue().equals(getQname(qname).toString())) { elementsSeq.add(0, this); } break; default: break; } return new BXMLSequence(elementsSeq); }
new OMChildrenQNameIterator(((OMElement) omNode).getFirstOMChild(), getQname(qname)); while (childrenItr.hasNext()) { childrenItr.next();
/** * {@inheritDoc} */ @Override public void removeAttribute(String qname) { synchronized (this) { if (freezeStatus.getState() != BVM.FreezeStatus.State.UNFROZEN) { handleInvalidUpdate(freezeStatus.getState()); } } if (nodeType != XMLNodeType.ELEMENT || qname.isEmpty()) { return; } OMElement omElement = (OMElement) omNode; OMAttribute attribute = omElement.getAttribute(getQname(qname)); if (attribute == null) { return; } omElement.removeAttribute(attribute); }
/** * {@inheritDoc} */ @Override public BXML<?> children(String qname) { BValueArray elementsSeq = new BValueArray(); switch (nodeType) { case ELEMENT: /* * Here we are not using "((OMElement) omNode).getChildrenWithName(qname))" method, since as per the * documentation of AxiomContainer.getChildrenWithName, if the namespace part of the qname is empty, it * will look for the elements which matches only the local part and returns. i.e: It will not match the * namespace. This is not the behavior we want. Hence we are explicitly creating an iterator which * will return elements that will match both namespace and the localName, regardless whether they are * empty or not. */ Iterator<OMNode> childrenItr = new OMChildrenQNameIterator(((OMElement) omNode).getFirstOMChild(), getQname(qname)); int i = 0; while (childrenItr.hasNext()) { OMNode node = childrenItr.next(); elementsSeq.add(i++, new BXMLItem(node)); } break; default: break; } return new BXMLSequence(elementsSeq); }