KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > style > XSLNextMatch


1 package net.sf.saxon.style;
2 import net.sf.saxon.expr.Expression;
3 import net.sf.saxon.expr.ExpressionTool;
4 import net.sf.saxon.instruct.Executable;
5 import net.sf.saxon.instruct.NextMatch;
6 import net.sf.saxon.om.*;
7 import net.sf.saxon.trans.XPathException;
8 import net.sf.saxon.type.Type;
9 import net.sf.saxon.value.Whitespace;
10
11 /**
12 * An xsl:next-match element in the stylesheet
13 */

14
15 public class XSLNextMatch extends StyleElement {
16
17
18     /**
19     * Determine whether this node is an instruction.
20     * @return true - it is an instruction
21     */

22
23     public boolean isInstruction() {
24         return true;
25     }
26
27     /**
28     * Determine whether this type of element is allowed to contain an xsl:fallback
29     * instruction
30     */

31
32     public boolean mayContainFallback() {
33         return true;
34     }
35
36     public void prepareAttributes() throws XPathException {
37
38         AttributeCollection atts = getAttributeList();
39
40         for (int a=0; a<atts.getLength(); a++) {
41             int nc = atts.getNameCode(a);
42             checkUnknownAttribute(nc);
43         }
44     }
45
46     public void validate() throws XPathException {
47         checkWithinTemplate();
48         AxisIterator kids = iterateAxis(Axis.CHILD);
49         while (true) {
50             NodeInfo child = (NodeInfo)kids.next();
51             if (child == null) {
52                 break;
53             }
54             if (child instanceof XSLWithParam || child instanceof XSLFallback) {
55                 // OK;
56
} else if (child.getNodeKind() == Type.TEXT) {
57                     // with xml:space=preserve, white space nodes may still be there
58
if (!Whitespace.isWhite(child.getStringValueCS())) {
59                     compileError("No character data is allowed within xsl:next-match", "XTSE0010");
60                 }
61             } else {
62                 compileError("Child element " + child.getDisplayName() +
63                         " is not allowed within xsl:next-match", "XTSE0010");
64             }
65         }
66
67     }
68
69     public Expression compile(Executable exec) throws XPathException {
70         NextMatch inst = new NextMatch(backwardsCompatibleModeIsEnabled());
71         inst.setActualParameters(getWithParamInstructions(exec, false, inst),
72                                  getWithParamInstructions(exec, true, inst));
73         ExpressionTool.makeParentReferences(inst);
74         return inst;
75     }
76
77 }
78
79 //
80
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
81
// you may not use this file except in compliance with the License. You may obtain a copy of the
82
// License at http://www.mozilla.org/MPL/
83
//
84
// Software distributed under the License is distributed on an "AS IS" basis,
85
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
86
// See the License for the specific language governing rights and limitations under the License.
87
//
88
// The Original Code is: all this file.
89
//
90
// The Initial Developer of the Original Code is Michael H. Kay.
91
//
92
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
93
//
94
// Contributor(s): none.
95
//
96
Popular Tags