Debian Codegraph @

net/sf/saxon/style/XSLOnEmpty.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.instruct.OnEmptyExpr;
12 import net.sf.saxon.om.AxisInfo;
13 import net.sf.saxon.trans.XPathException;
14
15
16 /**
17 * An xsl:on-empty element in the stylesheet. The rules are identical to xsl:sequence.
18 */
19
20 public final class XSLOnEmpty extends XSLSequence {
21
22 @Override
23 public void validate(ComponentDeclaration decl) throws XPathException {
24 super.validate(decl);
25 iterateAxis(AxisInfo.FOLLOWING_SIBLING).forEachOrFail(next -> {
26 if (!(next instanceof XSLFallback || next instanceof XSLCatch)) {
27 compileError("xsl:on-empty must be the last instruction in the sequence constructor");
28 }
29 });
30 }
31
32 @Override
33 public Expression compile(Compilation exec, ComponentDeclaration decl) throws XPathException {
34 Expression e = super.compile(exec, decl);
35 return new OnEmptyExpr(e);
36 }
37 }