KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icl > saxon > exslt > Common


1 package com.icl.saxon.exslt;
2 import com.icl.saxon.expr.*;
3
4 /**
5 * This class implements extension functions in the
6 * http://exslt.org/common namespace. <p>
7 */

8
9
10
11 public abstract class Common {
12
13     /**
14     * Convert a result tree fragment to a node-set.
15     */

16
17     public static NodeSetValue nodeSet(Value frag) throws XPathException {
18         if (frag instanceof SingletonNodeSet) {
19             ((SingletonNodeSet)frag).allowGeneralUse();
20         }
21         if (frag instanceof NodeSetValue) {
22             return (NodeSetValue)frag;
23         } else {
24             throw new XPathException("exslt:node-set(): argument must be a node-set or tree");
25         }
26     }
27
28     /**
29     * Return the type of the supplied value: "node-set", "string", "number", "boolean",
30     * "RTF", or "external"
31     */

32
33     public static String JavaDoc objectType(Value value) {
34         if (value instanceof FragmentValue || value instanceof TextFragmentValue) {
35             return "RTF";
36         } else if (value instanceof NodeSetValue) {
37             return "node-set";
38         } else if (value instanceof StringValue) {
39             return "string";
40         } else if (value instanceof NumericValue) {
41             return "number";
42         } else if (value instanceof BooleanValue) {
43             return "boolean";
44         } else {
45             return "external";
46         }
47     }
48
49
50 }
51
52
53
54
55
56 //
57
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
58
// you may not use this file except in compliance with the License. You may obtain a copy of the
59
// License at http://www.mozilla.org/MPL/
60
//
61
// Software distributed under the License is distributed on an "AS IS" basis,
62
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
63
// See the License for the specific language governing rights and limitations under the License.
64
//
65
// The Original Code is: all this file.
66
//
67
// The Initial Developer of the Original Code is
68
// Michael Kay of International Computers Limited (mhkay@iclway.co.uk).
69
//
70
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
71
//
72
// Contributor(s): none.
73
//
74
Popular Tags