Debian Codegraph @

net/sf/saxon/type/ValidationParams.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.type;
9
10 import net.sf.saxon.om.Sequence;
11 import net.sf.saxon.om.StructuredQName;
12 import net.sf.saxon.sxpath.XPathDynamicContext;
13 import net.sf.saxon.sxpath.XPathVariable;
14 import net.sf.saxon.trans.XPathException;
15
16 import java.util.HashMap;
17 import java.util.Map;
18
19 /**
20 * This class represents a collection of parameter values for use in schema validation;
21 * it defines values for the parameters declared using the saxon:param XSD extension.
22 * <p>The implementation is just a HashMap; giving the class a name helps type safety.</p>
23 */
24
25 public class ValidationParams extends HashMap<StructuredQName, Sequence<?>> {
26
27 public ValidationParams() {
28 super(20);
29 }
30
31 public static void setValidationParams(Map<StructuredQName, XPathVariable> declaredParams, ValidationParams actualParams, XPathDynamicContext context) throws XPathException {
32 for (StructuredQName p : declaredParams.keySet()) {
33 XPathVariable var = declaredParams.get(p);
34 Sequence<?> paramValue = actualParams.get(p);
35 if (paramValue != null) {
36 context.setVariable(var, paramValue);
37 } else {
38 context.setVariable(var, var.getDefaultValue());
39 }
40 }
41 }
42 }
43