001: package net.sf.saxon.om;
002:
003: /**
004: * This class is not instantiated, it exists to hold a set of constants representing known
005: * namespaces. For each of these, there is a constant for the namespace URI and for many of
006: * them, there is a numeric constant used as the code for this namespace in the name pool.
007: *
008: * <p>This class also defines constant URIs for some objects other than namespaces -
009: * for example, URIs that identify the various object models used in the JAXP XPath API,
010: * and the Unicode codepoint collation URI.</p>
011: *
012: * @author Michael H. Kay
013: */
014:
015: public class NamespaceConstant {
016:
017: /**
018: * A URI representing the null namespace (actually, an empty string)
019: */
020:
021: public static final String NULL = "";
022: /**
023: * The numeric code representing the null namespace (actually, zero)
024: */
025: public static final short NULL_CODE = 0;
026: /**
027: * The namespace code for the null namespace
028: */
029: public static final int NULL_NAMESPACE_CODE = 0;
030:
031: /**
032: * Fixed namespace name for XML: "http://www.w3.org/XML/1998/namespace".
033: */
034: public static final String XML = "http://www.w3.org/XML/1998/namespace";
035: /**
036: * Numeric code representing the XML namespace
037: */
038: public static final short XML_CODE = 1;
039: /**
040: * The namespace code for the XML namespace
041: */
042: public static final int XML_NAMESPACE_CODE = 0x00010001;
043:
044: /**
045: * Fixed namespace name for XSLT: "http://www.w3.org/1999/XSL/Transform"
046: */
047: public static final String XSLT = "http://www.w3.org/1999/XSL/Transform";
048: /**
049: * Numeric code representing the XSLT namespace
050: */
051: public static final short XSLT_CODE = 2;
052:
053: /**
054: * Fixed namespace name for SAXON: "http://saxon.sf.net/"
055: */
056: public static final String SAXON = "http://saxon.sf.net/";
057: /**
058: * Numeric code representing the SAXON namespace
059: */
060: public static final short SAXON_CODE = 3;
061:
062: /**
063: * Namespace name for XML Schema: "http://www.w3.org/2001/XMLSchema"
064: */
065: public static final String SCHEMA = "http://www.w3.org/2001/XMLSchema";
066: /**
067: * Numeric code representing the schema namespace
068: */
069: public static final short SCHEMA_CODE = 4;
070:
071: /**
072: * Namespace for additional XPath-defined data types:
073: * "http://www.w3.org/2005/04/xpath-datatypes"
074: */
075: public static final String XDT = "http://www.w3.org/2005/xpath-datatypes";
076:
077: /**
078: * Older versions of XDT namespace
079: */
080:
081: public static final String XDT200504 = "http://www.w3.org/2005/04/xpath-datatypes";
082: public static final String XDT200502 = "http://www.w3.org/2005/02/xpath-datatypes";
083: public static final String XDT200410 = "http://www.w3.org/2004/10/xpath-datatypes";
084: public static final String XDT200407 = "http://www.w3.org/2004/07/xpath-datatypes";
085:
086: /**
087: * Test whether a namespace is the XDT namespace
088: */
089:
090: public static final boolean isXDTNamespace(String uri) {
091: return uri.equals(XDT) || uri.equals(XDT200504)
092: || uri.equals(XDT200502) || uri.equals(XDT200410)
093: || uri.equals(XDT200407);
094: }
095:
096: /**
097: * Numeric code representing the schema namespace
098: */
099: public static final short XDT_CODE = 5;
100:
101: /**
102: * XML-schema-defined namespace for use in instance documents ("xsi")
103: */
104: public static final String SCHEMA_INSTANCE = "http://www.w3.org/2001/XMLSchema-instance";
105:
106: public static final short XSI_CODE = 6;
107:
108: /**
109: * Fixed namespace name for EXSLT/Common: "http://exslt.org/common"
110: */
111: public static final String EXSLT_COMMON = "http://exslt.org/common";
112:
113: /**
114: * Fixed namespace name for EXSLT/math: "http://exslt.org/math"
115: */
116: public static final String EXSLT_MATH = "http://exslt.org/math";
117:
118: /**
119: * Fixed namespace name for EXSLT/sets: "http://exslt.org/sets"
120: */
121: public static final String EXSLT_SETS = "http://exslt.org/sets";
122:
123: /**
124: * Fixed namespace name for EXSLT/date: "http://exslt.org/dates-and-times"
125: */
126: public static final String EXSLT_DATES_AND_TIMES = "http://exslt.org/dates-and-times";
127:
128: /**
129: * Fixed namespace name for EXSLT/random: "http://exslt.org/random"
130: */
131: public static final String EXSLT_RANDOM = "http://exslt.org/random";
132:
133: /**
134: * The standard namespace for functions and operators
135: */
136: public static final String FN = "http://www.w3.org/2005/xpath-functions";
137:
138: /**
139: * The standard namespace for system error codes
140: */
141: public static final String ERR = "http://www.w3.org/2005/xqt-errors";
142:
143: /**
144: * Predefined XQuery namespace for local functions
145: */
146: public static final String LOCAL = "http://www.w3.org/2005/xquery-local-functions";
147: /**
148: * Recognize the Microsoft namespace so we can give a suitably sarcastic error message
149: */
150:
151: public static final String MICROSOFT_XSL = "http://www.w3.org/TR/WD-xsl";
152:
153: /**
154: * The XHTML namespace http://www.w3.org/1999/xhtml
155: */
156:
157: public static final String XHTML = "http://www.w3.org/1999/xhtml";
158:
159: /**
160: * Namespace for types representing external Java objects
161: */
162:
163: public static final String JAVA_TYPE = "http://saxon.sf.net/java-type";
164:
165: /**
166: * Namespace for names allocated to anonymous types. This exists so that
167: * a name fingerprint can be allocated for use as a type annotation.
168: */
169:
170: public static final String ANONYMOUS = "http://ns.saxonica.com/anonymous-type";
171:
172: /**
173: * URI identifying the Saxon object model for use in the JAXP 1.3 XPath API
174: */
175:
176: public static final String OBJECT_MODEL_SAXON = "http://saxon.sf.net/jaxp/xpath/om";
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 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 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 CODEPOINT_COLLATION_URI = "http://www.w3.org/2005/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 uri) {
208: return uri.equals(XSLT) || uri.equals(FN) || uri.equals(XML)
209: || uri.equals(SCHEMA) || uri.equals(XDT)
210: || uri.equals(SCHEMA_INSTANCE);
211: }
212:
213: /**
214: * Determine whether a namespace is a reserved namespace
215: */
216:
217: public static final boolean isSpecialURICode(short uriCode) {
218: return uriCode <= 6;
219: }
220:
221: /**
222: * Determine whether a namespace is a reserved namespace
223: */
224:
225: public static final boolean isReservedInQuery(String uri) {
226: return uri.equals(FN) || uri.equals(XML) || uri.equals(SCHEMA)
227: || uri.equals(XDT) || uri.equals(SCHEMA_INSTANCE);
228: }
229: }
230:
231: //
232: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
233: // you may not use this file except in compliance with the License. You may obtain a copy of the
234: // License at http://www.mozilla.org/MPL/
235: //
236: // Software distributed under the License is distributed on an "AS IS" basis,
237: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
238: // See the License for the specific language governing rights and limitations under the License.
239: //
240: // The Original Code is: all this file.
241: //
242: // The Initial Developer of the Original Code is Michael H. Kay.
243: //
244: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
245: //
246: // Contributor(s): none.
247: //
|