Debian Codegraph @

net/sf/saxon/functions/BaseUri_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.Callable;
11 import net.sf.saxon.expr.XPathContext;
12 import net.sf.saxon.om.NodeInfo;
13 import net.sf.saxon.om.Sequence;
14 import net.sf.saxon.om.ZeroOrOne;
15 import net.sf.saxon.trans.XPathException;
16 import net.sf.saxon.value.AnyURIValue;
17
18 /**
19 * This class implements the fn:base-uri() function in XPath 2.0
20 */
21
22 public class BaseUri_1 extends SystemFunction implements Callable {
23
24 public ZeroOrOne<AnyURIValue> call(XPathContext context, Sequence[] arguments) throws XPathException {
25 NodeInfo node = (NodeInfo)arguments[0].head();
26 if (node == null) {
27 return ZeroOrOne.empty();
28 }
29 String s = node.getBaseURI();
30 if (s == null) {
31 return ZeroOrOne.empty();
32 }
33 return new ZeroOrOne<>(new AnyURIValue(s));
34
35 }
36
37 public String getCompilerName() {
38 return "BaseURICompiler";
39 }
40
41 }
42