KickJava   Java API By Example, From Geeks To Geeks.

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


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.Namespace;
6 import net.sf.saxon.om.AttributeCollection;
7 import net.sf.saxon.value.StringValue;
8 import net.sf.saxon.trans.XPathException;
9
10 import javax.xml.transform.TransformerConfigurationException JavaDoc;
11
12 /**
13 * An xsl:namespace element in the stylesheet. (XSLT 2.0)
14 */

15
16 public class XSLNamespace extends XSLStringConstructor {
17
18     Expression name;
19
20     public void prepareAttributes() throws XPathException {
21
22         String JavaDoc nameAtt = null;
23         String JavaDoc selectAtt = null;
24
25         AttributeCollection atts = getAttributeList();
26
27         for (int a=0; a<atts.getLength(); a++) {
28             int nc = atts.getNameCode(a);
29             String JavaDoc f = getNamePool().getClarkName(nc);
30             if (f==StandardNames.NAME) {
31                 nameAtt = atts.getValue(a).trim();
32             } else if (f==StandardNames.SELECT) {
33                 selectAtt = atts.getValue(a).trim();
34             } else {
35                 checkUnknownAttribute(nc);
36             }
37         }
38         if (nameAtt==null) {
39             reportAbsence("name");
40         } else {
41             name = makeAttributeValueTemplate(nameAtt);
42         }
43
44         if (selectAtt!=null) {
45             select = makeExpression(selectAtt);
46         }
47
48     }
49
50     public void validate() throws XPathException {
51         checkWithinTemplate();
52         name = typeCheck("name", name);
53         select = typeCheck("select", select);
54         super.validate();
55     }
56
57     public Expression compile(Executable exec) throws XPathException {
58         Namespace inst = new Namespace(name);
59         compileContent(exec, inst, StringValue.SINGLE_SPACE);
60         ExpressionTool.makeParentReferences(inst);
61         return inst;
62     }
63
64 }
65
66 //
67
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
68
// you may not use this file except in compliance with the License. You may obtain a copy of the
69
// License at http://www.mozilla.org/MPL/
70
//
71
// Software distributed under the License is distributed on an "AS IS" basis,
72
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
73
// See the License for the specific language governing rights and limitations under the License.
74
//
75
// The Original Code is: all this file.
76
//
77
// The Initial Developer of the Original Code is Michael H. Kay.
78
//
79
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
80
//
81
// Contributor(s): none.
82
//
83
Popular Tags