Debian Codegraph @

net/sf/saxon/style/XSLComment.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.expr.Expression;
11 import net.sf.saxon.expr.StringLiteral;
12 import net.sf.saxon.expr.instruct.Comment;
13 import net.sf.saxon.om.AttributeCollection;
14 import net.sf.saxon.trans.XPathException;
15 import net.sf.saxon.value.StringValue;
16
17 /**
18 * An xsl:comment elements in the stylesheet. <br>
19 */
20
21 public final class XSLComment extends XSLLeafNodeConstructor {
22
23 public void prepareAttributes() throws XPathException {
24
25 String selectAtt = null;
26
27 AttributeCollection atts = getAttributeList();
28 for (int a = 0; a < atts.getLength(); a++) {
29 String f = atts.getQName(a);
30 if (f.equals("select")) {
31 selectAtt = atts.getValue(a);
32 select = makeExpression(selectAtt, a);
33 } else {
34 checkUnknownAttribute(atts.getNodeName(a));
35 }
36 }
37
38 }
39
40 public void validate(ComponentDeclaration decl) throws XPathException {
41 select = typeCheck("select", select);
42 super.validate(decl);
43 }
44
45 /**
46 * Get the error code to be returned when the element has a select attribute but is not empty.
47 *
48 * @return the error code defined for this condition, for this particular instruction
49 */
50
51 protected String getErrorCodeForSelectPlusContent() {
52 return "XTSE0940";
53 }
54
55 /*@NotNull*/
56 public Expression compile(Compilation exec, ComponentDeclaration decl) throws XPathException {
57 Comment inst = new Comment();
58 compileContent(exec, decl, inst, new StringLiteral(StringValue.SINGLE_SPACE));
59 return inst;
60 }
61
62 }