KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > style > SAXONAssign


1 package com.icl.saxon.style;
2 import com.icl.saxon.*;
3 import com.icl.saxon.expr.*;
4 import javax.xml.transform.*;
5 import java.io.*;
6
7 /**
8 * saxon:assign element in stylesheet.<BR>
9 * The saxon:assign element has mandatory attribute name and optional attribute expr.
10 * It also allows xsl:extension-element-prefixes etc.
11 */

12
13 public class SAXONAssign extends XSLGeneralVariable {
14
15     private Binding binding; // link to the variable declaration
16

17     /**
18     * Determine whether this node is an instruction.
19     * @return true - it is an instruction
20     */

21
22     public boolean isInstruction() {
23         return true;
24     }
25
26
27     public void validate() throws TransformerConfigurationException {
28         checkWithinTemplate();
29         super.validate();
30         try {
31             binding = bindVariable(getVariableFingerprint());
32         } catch (XPathException err) {
33             // variable not declared
34
compileError(err.getMessage());
35             return;
36         }
37         if (!binding.isAssignable()) {
38             compileError("Variable " + getVariableName() + " is not marked as assignable");
39         }
40     }
41
42     public boolean isAssignable() { // this variable is assignable by definition
43
return true;
44     }
45
46     public void process(Context context) throws TransformerException
47     {
48         Value value = getSelectValue(context);
49         context.getController().getBindery().assignVariable(binding, value);
50     }
51
52 }
53
54 //
55
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
56
// you may not use this file except in compliance with the License. You may obtain a copy of the
57
// License at http://www.mozilla.org/MPL/
58
//
59
// Software distributed under the License is distributed on an "AS IS" basis,
60
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
61
// See the License for the specific language governing rights and limitations under the License.
62
//
63
// The Original Code is: all this file.
64
//
65
// The Initial Developer of the Original Code is
66
// Michael Kay of International Computers Limited (mhkay@iclway.co.uk).
67
//
68
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
69
//
70
// Contributor(s): none.
71
//
72
Popular Tags