KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > exslt > Common


1 package net.sf.saxon.exslt;
2 import net.sf.saxon.expr.XPathContext;
3 import net.sf.saxon.pattern.AnyNodeTest;
4 import net.sf.saxon.type.ItemType;
5 import net.sf.saxon.type.Type;
6 import net.sf.saxon.value.Value;
7
8 /**
9 * This class implements extension functions in the
10 * http://exslt.org/common namespace. <p>
11 */

12
13
14
15 public abstract class Common {
16
17     /**
18      * Class is not instantiated
19      */

20     private Common() {
21     }
22
23     /**
24     * Convert a result tree fragment to a node-set. This is a hangover from XSLT 1.0;
25     * it is implemented as a no-op.
26     */

27
28     public static Value nodeSet(Value frag) {
29         return frag;
30     }
31
32     /**
33     * Return the type of the supplied value: "sequence", "string", "number", "boolean",
34     * "external". (EXSLT spec not yet modified to cater for XPath 2.0 data model)
35     */

36
37     public static String JavaDoc objectType(XPathContext context, Value value) {
38         ItemType type = value.getItemType();
39         if (Type.isSubType(type, AnyNodeTest.getInstance())) {
40             return "node-set";
41         } else if (Type.isSubType(type, Type.STRING_TYPE)) {
42             return "string";
43         } else if (Type.isSubType(type, Type.NUMBER_TYPE)) {
44             return "number";
45         } else if (Type.isSubType(type, Type.BOOLEAN_TYPE)) {
46             return "boolean";
47         } else {
48             return type.toString(context.getController().getNamePool());
49         }
50     }
51
52
53 }
54
55
56
57
58
59 //
60
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
61
// you may not use this file except in compliance with the License. You may obtain a copy of the
62
// License at http://www.mozilla.org/MPL/
63
//
64
// Software distributed under the License is distributed on an "AS IS" basis,
65
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
66
// See the License for the specific language governing rights and limitations under the License.
67
//
68
// The Original Code is: all this file.
69
//
70
// The Initial Developer of the Original Code is Michael H. Kay.
71
//
72
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
73
//
74
// Contributor(s): none.
75
//
76
Popular Tags