Debian Codegraph @

net/sf/saxon/functions/HasChildren_1.java

raw symbols SCIP
1 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 // Copyright (c) 2018 Saxonica Limited.
3 // This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
4 // If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 // This Source Code Form is "Incompatible With Secondary Licenses", as defined by the Mozilla Public License, v. 2.0.
6 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7
8 package net.sf.saxon.functions;
9
10 import net.sf.saxon.expr.XPathContext;
11 import net.sf.saxon.om.NodeInfo;
12 import net.sf.saxon.om.Sequence;
13 import net.sf.saxon.trans.XPathException;
14 import net.sf.saxon.value.BooleanValue;
15
16 /**
17 * This class implements the function fn:has-children($node), which is a standard function in XPath 3.0
18 */
19
20 public class HasChildren_1 extends SystemFunction {
21
22 /**
23 * Evaluate the function dynamically
24 *
25 * @param context the dynamic evaluation context
26 * @param arguments the values of the arguments, supplied as Sequences
27 * @return the result of the evaluation, in the form of a Sequence
28 * @throws net.sf.saxon.trans.XPathException
29 * if a dynamic error occurs during the evaluation of the expression
30 */
31 public BooleanValue call(XPathContext context, Sequence[] arguments) throws XPathException {
32 NodeInfo arg = (NodeInfo) arguments[0].head();
33 if (arg == null) {
34 return BooleanValue.FALSE;
35 }
36 return BooleanValue.get(arg.hasChildNodes());
37 }
38 }
39
40 // Copyright (c) 2012-2015 Saxonica Limited.