KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > instruct > AttributeSet


1 package net.sf.saxon.instruct;
2 import net.sf.saxon.expr.XPathContext;
3 import net.sf.saxon.expr.XPathContextMajor;
4 import net.sf.saxon.style.StandardNames;
5 import net.sf.saxon.trace.InstructionInfo;
6 import net.sf.saxon.trace.InstructionInfoProvider;
7 import net.sf.saxon.trans.XPathException;
8
9 /**
10 * The compiled form of an xsl:attribute-set element in the stylesheet.
11 */

12
13 // Note, there is no run-time check for circularity. This is checked at compile time.
14

15 public class AttributeSet extends Procedure implements InstructionInfoProvider {
16
17     int nameCode;
18
19     private AttributeSet[] useAttributeSets;
20
21     public AttributeSet() {}
22
23     public void setNameCode(int nameCode) {
24         this.nameCode = nameCode;
25     }
26
27     public int getNameCode() {
28         return nameCode;
29     }
30
31     public void setUseAttributeSets(AttributeSet[] useAttributeSets) {
32         this.useAttributeSets = useAttributeSets;
33     }
34
35     public void setStackFrameMap(SlotManager stackFrameMap) {
36         if (stackFrameMap != null && stackFrameMap.getNumberOfVariables() > 0) {
37             super.setStackFrameMap(stackFrameMap);
38         }
39     }
40
41     public void expand(XPathContext context) throws XPathException {
42         // apply the content of any attribute sets mentioned in use-attribute-sets
43

44         if (useAttributeSets != null) {
45             AttributeSet.expand(useAttributeSets, context);
46         }
47
48         if (getStackFrameMap() != null) {
49             XPathContextMajor c2 = context.newContext();
50             c2.setOrigin(this);
51             c2.openStackFrame(getStackFrameMap());
52             getBody().process(c2);
53         } else {
54             getBody().process(context);
55         }
56     }
57
58     /**
59      * Get the InstructionInfo details about the construct. This information isn't used for tracing,
60      * but it is available when inspecting the context stack.
61      */

62
63     public InstructionInfo getInstructionInfo() {
64         InstructionDetails details = new InstructionDetails();
65         details.setConstructType(StandardNames.XSL_ATTRIBUTE_SET);
66         details.setSystemId(getSystemId());
67         details.setLineNumber(getLineNumber());
68         details.setProperty("attribute-set", this);
69         return details;
70     }
71
72     /**
73      * Expand an array of attribute sets
74      * @param asets the attribute sets to be expanded
75      * @param context the run-time context to use
76      * @throws XPathException
77      */

78
79     protected static void expand(AttributeSet[] asets, XPathContext context) throws XPathException {
80         for (int i=0; i<asets.length; i++) {
81             asets[i].expand(context);
82         }
83     }
84 }
85
86 //
87
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
88
// you may not use this file except in compliance with the License. You may obtain a copy of the
89
// License at http://www.mozilla.org/MPL/
90
//
91
// Software distributed under the License is distributed on an "AS IS" basis,
92
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
93
// See the License for the specific language governing rights and limitations under the License.
94
//
95
// The Original Code is: all this file.
96
//
97
// The Initial Developer of the Original Code is Michael H. Kay.
98
//
99
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
100
//
101
// Contributor(s): none.
102
//
103
Popular Tags