Debian Codegraph @

net/sf/saxon/functions/Tokenize_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.Sequence;
12 import net.sf.saxon.om.SequenceTool;
13 import net.sf.saxon.trans.XPathException;
14 import net.sf.saxon.value.AtomicValue;
15 import net.sf.saxon.value.EmptySequence;
16 import net.sf.saxon.value.Whitespace;
17
18
19 /**
20 * This class implements the single-argument tokenize() function introduced in XPath 3.1
21 */
22
23 public class Tokenize_1 extends SystemFunction {
24
25 /**
26 * Evaluate the expression dynamically
27 *
28 * @param context the dynamic evaluation context
29 * @param arguments the values of the arguments, supplied as SequenceIterators
30 * @return the result of the evaluation, in the form of a SequenceIterator
31 * @throws net.sf.saxon.trans.XPathException
32 * if a dynamic error occurs during the evaluation of the expression
33 */
34 public Sequence<?> call(XPathContext context, Sequence[] arguments) throws XPathException {
35 AtomicValue sv = (AtomicValue) arguments[0].head();
36 if (sv == null) {
37 return EmptySequence.getInstance();
38 }
39 CharSequence input = sv.getStringValueCS();
40 return SequenceTool.toLazySequence(new Whitespace.Tokenizer(input));
41 }
42 }
43