Search in sources :

Example 1 with NodeIterator

use of org.loboevolution.html.node.NodeIterator in project LoboEvolution by LoboEvolution.

the class XPathResultImpl method getSingleNodeValue.

/**
 * {@inheritDoc}
 */
@Override
public Node getSingleNodeValue() throws XPathException {
    if (m_resultType != ANY_UNORDERED_NODE_TYPE && m_resultType != FIRST_ORDERED_NODE_TYPE) {
        String fmsg = XPATHMessages.createXPATHMessage(XPATHErrorResources.ER_CANT_CONVERT_TO_SINGLENODE, new Object[] { m_xpath.getPatternString(), getTypeString(m_resultType) });
        throw new XPathException(XPathException.TYPE_ERR, fmsg);
    // "The XPathResult of XPath expression {0} has an XPathResultType
    // of {1} which cannot be converted to a single node.
    // This method applies only to types ANY_UNORDERED_NODE_TYPE and
    // FIRST_ORDERED_NODE_TYPE."
    }
    NodeIterator result = null;
    if (null == result) {
        return null;
    }
    Node node = result.nextNode();
    if (isNamespaceNode(node)) {
        return new XPathNamespaceImpl(node);
    } else {
        return node;
    }
}
Also used : NodeIterator(org.loboevolution.html.node.NodeIterator) XPathException(org.loboevolution.html.xpath.XPathException) Node(org.loboevolution.html.node.Node)

Aggregations

Node (org.loboevolution.html.node.Node)1 NodeIterator (org.loboevolution.html.node.NodeIterator)1 XPathException (org.loboevolution.html.xpath.XPathException)1