KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > saxon > om > NamespaceConstant


1 package net.sf.saxon.om;
2
3 /**
4  * This class is not instantiated, it exists to hold a set of constants representing known
5  * namespaces. For each of these, there is a constant for the namespace URI and for many of
6  * them, there is a numeric constant used as the code for this namespace in the name pool.
7  *
8  * <p>This class also defines constant URIs for some objects other than namespaces -
9  * for example, URIs that identify the various object models used in the JAXP XPath API,
10  * and the Unicode codepoint collation URI.</p>
11  *
12  * @author Michael H. Kay
13  */

14
15 public class NamespaceConstant {
16
17     /**
18      * A URI representing the null namespace (actually, an empty string)
19      */

20
21     public static final String JavaDoc NULL = "";
22     /**
23      * The numeric code representing the null namespace (actually, zero)
24      */

25     public static final short NULL_CODE = 0;
26     /**
27      * The namespace code for the null namespace
28      */

29     public static final int NULL_NAMESPACE_CODE = 0;
30
31     /**
32      * Fixed namespace name for XML: "http://www.w3.org/XML/1998/namespace".
33      */

34     public static final String JavaDoc XML = "http://www.w3.org/XML/1998/namespace";
35     /**
36      * Numeric code representing the XML namespace
37      */

38     public static final short XML_CODE = 1;
39     /**
40      * The namespace code for the XML namespace
41      */

42     public static final int XML_NAMESPACE_CODE = 0x00010001;
43
44
45     /**
46      * Fixed namespace name for XSLT: "http://www.w3.org/1999/XSL/Transform"
47      */

48     public static final String JavaDoc XSLT = "http://www.w3.org/1999/XSL/Transform";
49     /**
50      * Numeric code representing the XSLT namespace
51      */

52     public static final short XSLT_CODE = 2;
53
54     /**
55      * Fixed namespace name for SAXON: "http://saxon.sf.net/"
56      */

57     public static final String JavaDoc SAXON = "http://saxon.sf.net/";
58     /**
59      * Numeric code representing the SAXON namespace
60      */

61     public static final short SAXON_CODE = 3;
62
63     /**
64      * Namespace name for XML Schema: "http://www.w3.org/2001/XMLSchema"
65      */

66     public static final String JavaDoc SCHEMA = "http://www.w3.org/2001/XMLSchema";
67     /**
68      * Numeric code representing the schema namespace
69      */

70     public static final short SCHEMA_CODE = 4;
71
72     /**
73      * Namespace for additional XPath-defined data types:
74      * "http://www.w3.org/2005/04/xpath-datatypes"
75      */

76     public static final String JavaDoc XDT = "http://www.w3.org/2005/04/xpath-datatypes";
77
78     /**
79      * Older versions of XDT namespace
80      */

81
82     public static final String JavaDoc XDT200502 = "http://www.w3.org/2005/02/xpath-datatypes";
83     public static final String JavaDoc XDT200410 = "http://www.w3.org/2004/10/xpath-datatypes";
84     public static final String JavaDoc XDT200407 = "http://www.w3.org/2004/07/xpath-datatypes";
85
86     /**
87      * Test whether a namespace is the XDT namespace
88      */

89
90     public static final boolean isXDTNamespace(String JavaDoc uri) {
91         return uri.equals(XDT) || uri.equals(XDT200502) || uri.equals(XDT200410) || uri.equals(XDT200407);
92     }
93
94     /**
95      * Numeric code representing the schema namespace
96      */

97     public static final short XDT_CODE = 5;
98
99     /**
100      * XML-schema-defined namespace for use in instance documents ("xsi")
101      */

102     public static final String JavaDoc SCHEMA_INSTANCE = "http://www.w3.org/2001/XMLSchema-instance";
103
104     public static final short XSI_CODE = 6;
105
106     /**
107      * Fixed namespace name for EXSLT/Common: "http://exslt.org/common"
108      */

109     public static final String JavaDoc EXSLT_COMMON = "http://exslt.org/common";
110
111     /**
112      * Fixed namespace name for EXSLT/math: "http://exslt.org/math"
113      */

114     public static final String JavaDoc EXSLT_MATH = "http://exslt.org/math";
115
116     /**
117      * Fixed namespace name for EXSLT/sets: "http://exslt.org/sets"
118      */

119     public static final String JavaDoc EXSLT_SETS = "http://exslt.org/sets";
120
121     /**
122      * Fixed namespace name for EXSLT/date: "http://exslt.org/dates-and-times"
123      */

124     public static final String JavaDoc EXSLT_DATES_AND_TIMES = "http://exslt.org/dates-and-times";
125
126     /**
127      * Fixed namespace name for EXSLT/random: "http://exslt.org/random"
128      */

129     public static final String JavaDoc EXSLT_RANDOM = "http://exslt.org/random";
130
131     /**
132      * The standard namespace for functions and operators
133      */

134     public static final String JavaDoc FN = "http://www.w3.org/2005/04/xpath-functions";
135
136     /**
137      * The standard namespace for system error codes
138      */

139     public static final String JavaDoc ERR = "http://www.w3.org/2004/07/xqt-errors";
140
141
142     /**
143      * Predefined XQuery namespace for local functions
144      */

145     public static final String JavaDoc LOCAL = "http://www.w3.org/2005/04/xquery-local-functions";
146     /**
147      * Recognize the Microsoft namespace so we can give a suitably sarcastic error message
148      */

149
150     public static final String JavaDoc MICROSOFT_XSL = "http://www.w3.org/TR/WD-xsl";
151
152     /**
153      * The XHTML namespace http://www.w3.org/1999/xhtml
154      */

155
156     public static final String JavaDoc XHTML = "http://www.w3.org/1999/xhtml";
157
158     /**
159      * Namespace for types representing external Java objects
160      */

161
162     public static final String JavaDoc JAVA_TYPE = "http://saxon.sf.net/java-type";
163
164     /**
165      * Namespace for names allocated to anonymous types. This exists so that
166      * a name fingerprint can be allocated for use as a type annotation.
167      */

168
169     public static final String JavaDoc ANONYMOUS = "http://ns.saxonica.com/anonymous-type";
170
171     /**
172      * URI identifying the Saxon object model for use in the JAXP 1.3 XPath API
173      */

174
175     public static final String JavaDoc OBJECT_MODEL_SAXON = "http://saxon.sf.net/jaxp/xpath/om";
176
177
178     /**
179      * URI identifying the XOM object model for use in the JAXP 1.3 XPath API
180      */

181
182     public static final String JavaDoc OBJECT_MODEL_XOM = "http://www.xom.nu/jaxp/xpath/xom";
183
184     /**
185      * URI identifying the JDOM object model for use in the JAXP 1.3 XPath API
186      */

187
188     public static final String JavaDoc OBJECT_MODEL_JDOM = "http://jdom.org/jaxp/xpath/jdom";
189
190     /**
191      * URI identifying the Unicode codepoint collation
192      */

193
194     public static final String JavaDoc CODEPOINT_COLLATION_URI = "http://www.w3.org/2005/04/xpath-functions/collation/codepoint";
195
196     /**
197      * Private constructor: class is never instantiated
198      */

199
200     private NamespaceConstant() {
201     }
202
203     /**
204      * Determine whether a namespace is a reserved namespace
205      */

206
207     public static final boolean isReserved(String JavaDoc uri) {
208         return uri.equals(XSLT) ||
209                 uri.equals(FN) ||
210                 uri.equals(XML) ||
211                 uri.equals(SCHEMA)||
212                 uri.equals(XDT) ||
213                 uri.equals(SCHEMA_INSTANCE);
214     }
215
216     /**
217      * Determine whether a namespace is a reserved namespace
218      */

219
220     public static final boolean isReservedInQuery(String JavaDoc uri) {
221         return uri.equals(FN) ||
222                 uri.equals(XML) ||
223                 uri.equals(SCHEMA) ||
224                 uri.equals(XDT) ||
225                 uri.equals(SCHEMA_INSTANCE);
226     }
227 }
228
229 //
230
// The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
231
// you may not use this file except in compliance with the License. You may obtain a copy of the
232
// License at http://www.mozilla.org/MPL/
233
//
234
// Software distributed under the License is distributed on an "AS IS" basis,
235
// WITHOUT WARRANTY OF ANY KIND, either express or implied.
236
// See the License for the specific language governing rights and limitations under the License.
237
//
238
// The Original Code is: all this file.
239
//
240
// The Initial Developer of the Original Code is Michael H. Kay.
241
//
242
// Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
243
//
244
// Contributor(s): none.
245
//
246
Popular Tags