Debian Codegraph @

net/sf/saxon/style/XSLModuleRoot.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.style;
9
10 import net.sf.saxon.om.AxisInfo;
11 import net.sf.saxon.trans.XPathException;
12
13 /**
14 * Class representing xsl:stylesheet, xsl:transform, or xsl:package
15 */
16 public abstract class XSLModuleRoot extends StyleElement {
17
18 public static final int ANNOTATION_UNSPECIFIED = 0;
19 public static final int ANNOTATION_STRIP = 1;
20 public static final int ANNOTATION_PRESERVE = 2;
21
22 /**
23 * Ask whether it is required that modes be explicitly declared
24 *
25 * @return true if modes referenced within this package be explicitly declared
26 */
27
28 public boolean isDeclaredModes() {
29 return false;
30 }
31
32 /**
33 * Process the attributes of every node in the stylesheet module
34 */
35
36 public void processAllAttributes() throws XPathException {
37 prepareAttributes();
38 iterateAxis(AxisInfo.CHILD).forEach(node -> {
39 if (node instanceof StyleElement) {
40 try {
41 ((StyleElement) node).processAllAttributes();
42 } catch (XPathException err) {
43 ((StyleElement) node).compileError(err);
44 }
45 }
46 });
47 }
48
49
50 @Override
51 public void index(ComponentDeclaration decl, PrincipalStylesheetModule top) {
52 compileError(getDisplayName() + " can appear only as the outermost element", "XTSE0010");
53 }
54
55 /**
56 * Get the value of the input-type-annotations attribute, for this module alone.
57 * The value is an or-ed combination of the two bits
58 * {@link #ANNOTATION_STRIP} and {@link #ANNOTATION_PRESERVE}
59 *
60 * @return the value if the input-type-annotations attribute in this stylesheet module
61 */
62
63 public int getInputTypeAnnotationsAttribute() {
64 String inputTypeAnnotationsAtt = getAttributeValue("", "input-type-annotations");
65 if (inputTypeAnnotationsAtt != null) {
66 switch (inputTypeAnnotationsAtt) {
67 case "strip":
68 return ANNOTATION_STRIP;
69 case "preserve":
70 return ANNOTATION_PRESERVE;
71 case "unspecified":
72 return ANNOTATION_UNSPECIFIED;
73 default:
74 compileError("Invalid value for input-type-annotations attribute. " +
75 "Permitted values are (strip, preserve, unspecified)", "XTSE0020");
76 return ANNOTATION_UNSPECIFIED;
77 }
78 }
79 return -1;
80 }
81
82 }
83