1/*
2 * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package javax.xml;
27
28/**
29 * <p>Utility class to contain basic XML values as constants.
30 *
31 * @author <a href="mailto:Jeff.Suttor@Sun.com">Jeff Suttor</a>
32 * @see <a href="http://www.w3.org/TR/xml11/">Extensible Markup Language (XML) 1.1</a>
33 * @see <a href="http://www.w3.org/TR/REC-xml">Extensible Markup Language (XML) 1.0 (Second Edition)</a>
34 * @see <a href="http://www.w3.org/XML/xml-V10-2e-errata">XML 1.0 Second Edition Specification Errata</a>
35 * @see <a href="http://www.w3.org/TR/xml-names11/">Namespaces in XML 1.1</a>
36 * @see <a href="http://www.w3.org/TR/REC-xml-names">Namespaces in XML</a>
37 * @see <a href="http://www.w3.org/XML/xml-names-19990114-errata">Namespaces in XML Errata</a>
38 * @see <a href="http://www.w3.org/TR/xmlschema-1/">XML Schema Part 1: Structures</a>
39 * @since 1.5
40 **/
41
42public final class XMLConstants {
43
44    /**
45     * Private constructor to prevent instantiation.
46     */
47    private XMLConstants() {
48    }
49
50    /**
51     * Namespace URI to use to represent that there is no Namespace.
52     *
53     * <p>Defined by the Namespace specification to be "".
54     *
55     * @see <a href="http://www.w3.org/TR/REC-xml-names/#defaulting">
56     * Namespaces in XML, 5.2 Namespace Defaulting</a>
57     */
58    public static final String NULL_NS_URI = "";
59
60    /**
61     * Prefix to use to represent the default XML Namespace.
62     *
63     * <p>Defined by the XML specification to be "".
64     *
65     * @see <a
66     * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">
67     * Namespaces in XML, 3. Qualified Names</a>
68     */
69    public static final String DEFAULT_NS_PREFIX = "";
70
71    /**
72     * The official XML Namespace name URI.
73     *
74     * <p>Defined by the XML specification to be
75     * "{@code http://www.w3.org/XML/1998/namespace}".
76     *
77     * @see <a
78     * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">
79     * Namespaces in XML, 3. Qualified Names</a>
80     */
81    public static final String XML_NS_URI =
82        "http://www.w3.org/XML/1998/namespace";
83
84    /**
85     * The official XML Namespace prefix.
86     *
87     * <p>Defined by the XML specification to be "{@code xml}".
88     *
89     * @see <a
90     * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">
91     * Namespaces in XML, 3. Qualified Names</a>
92     */
93    public static final String XML_NS_PREFIX = "xml";
94
95    /**
96     * The official XML attribute used for specifying XML Namespace
97     * declarations, {@link #XMLNS_ATTRIBUTE
98     * XMLConstants.XMLNS_ATTRIBUTE}, Namespace name URI.
99     *
100     * <p>Defined by the XML specification to be
101     * "{@code http://www.w3.org/2000/xmlns/}".
102     *
103     * @see <a
104     * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">
105     * Namespaces in XML, 3. Qualified Names</a>
106     * @see <a
107     * href="http://www.w3.org/XML/xml-names-19990114-errata">
108     * Namespaces in XML Errata</a>
109     */
110    public static final String XMLNS_ATTRIBUTE_NS_URI =
111        "http://www.w3.org/2000/xmlns/";
112
113    /**
114     * The official XML attribute used for specifying XML Namespace
115     * declarations.
116     *
117     * <p>It is <strong><em>NOT</em></strong> valid to use as a
118     * prefix.  Defined by the XML specification to be
119     * "{@code xmlns}".
120     *
121     * @see <a
122     * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">
123     * Namespaces in XML, 3. Qualified Names</a>
124     */
125    public static final String XMLNS_ATTRIBUTE = "xmlns";
126
127    /**
128     * W3C XML Schema Namespace URI.
129     *
130     * <p>Defined to be "{@code http://www.w3.org/2001/XMLSchema}".
131     *
132     * @see <a href=
133     *  "http://www.w3.org/TR/xmlschema-1/#Instance_Document_Constructions">
134     *  XML Schema Part 1:
135     *  Structures, 2.6 Schema-Related Markup in Documents Being Validated</a>
136     */
137    public static final String W3C_XML_SCHEMA_NS_URI =
138        "http://www.w3.org/2001/XMLSchema";
139
140    /**
141     * W3C XML Schema Instance Namespace URI.
142     *
143     * <p>Defined to be "{@code http://www.w3.org/2001/XMLSchema-instance}".
144     *
145     * @see <a href=
146     *  "http://www.w3.org/TR/xmlschema-1/#Instance_Document_Constructions">
147     *  XML Schema Part 1:
148     *  Structures, 2.6 Schema-Related Markup in Documents Being Validated</a>
149     */
150    public static final String W3C_XML_SCHEMA_INSTANCE_NS_URI =
151        "http://www.w3.org/2001/XMLSchema-instance";
152
153    /**
154     * W3C XPath Datatype Namespace URI.
155     *
156     * <p>Defined to be "{@code http://www.w3.org/2003/11/xpath-datatypes}".
157     *
158     * @see <a href="http://www.w3.org/TR/xpath-datamodel">XQuery 1.0 and XPath 2.0 Data Model</a>
159     */
160    public static final String W3C_XPATH_DATATYPE_NS_URI = "http://www.w3.org/2003/11/xpath-datatypes";
161
162    /**
163     * XML Document Type Declaration Namespace URI as an arbitrary value.
164     *
165     * <p>Since not formally defined by any existing standard, arbitrarily define to be "{@code http://www.w3.org/TR/REC-xml}".
166     */
167    public static final String XML_DTD_NS_URI = "http://www.w3.org/TR/REC-xml";
168
169        /**
170         * RELAX NG Namespace URI.
171         *
172         * <p>Defined to be "{@code http://relaxng.org/ns/structure/1.0}".
173         *
174         * @see <a href="http://relaxng.org/spec-20011203.html">RELAX NG Specification</a>
175         */
176        public static final String RELAXNG_NS_URI = "http://relaxng.org/ns/structure/1.0";
177
178        /**
179         * Feature for secure processing.
180         *
181         * <ul>
182         *   <li>
183         *     {@code true} instructs the implementation to process XML securely.
184         *     This may set limits on XML constructs to avoid conditions such as denial of service attacks.
185         *   </li>
186         *   <li>
187         *     {@code false} instructs the implementation to process XML in accordance with the XML specifications
188         *     ignoring security issues such as limits on XML constructs to avoid conditions such as denial of service attacks.
189         *   </li>
190         * </ul>
191         */
192        public static final String FEATURE_SECURE_PROCESSING = "http://javax.xml.XMLConstants/feature/secure-processing";
193
194
195        /**
196         * Property: accessExternalDTD
197         *
198         * <p>
199         * Restrict access to external DTDs and external Entity References to the protocols specified.
200         * If access is denied due to the restriction of this property, a runtime exception that
201         * is specific to the context is thrown. In the case of {@link javax.xml.parsers.SAXParser}
202         * for example, {@link org.xml.sax.SAXException} is thrown.
203         *
204         * <p>
205         * <b>Value: </b> a list of protocols separated by comma. A protocol is the scheme portion of a
206         * {@link java.net.URI}, or in the case of the JAR protocol, "jar" plus the scheme portion
207         * separated by colon.
208         * A scheme is defined as:
209         *
210         * <blockquote>
211         * scheme = alpha *( alpha | digit | "+" | "-" | "." )<br>
212         * where alpha = a-z and A-Z.<br><br>
213         *
214         * And the JAR protocol:<br>
215         *
216         * jar[:scheme]<br><br>
217         *
218         * Protocols including the keyword "jar" are case-insensitive. Any whitespaces as defined by
219         * {@link java.lang.Character#isSpaceChar } in the value will be ignored.
220         * Examples of protocols are file, http, jar:file.
221         *
222         * </blockquote>
223         *
224         *<p>
225         * <b>Default value:</b> The default value is implementation specific and therefore not specified.
226         * The following options are provided for consideration:
227         * <blockquote>
228         * <UL>
229         *     <LI>an empty string to deny all access to external references;</LI>
230         *     <LI>a specific protocol, such as file, to give permission to only the protocol;</LI>
231         *     <LI>the keyword "all" to grant  permission to all protocols.</LI>
232         * </UL><br>
233         *      When FEATURE_SECURE_PROCESSING is enabled,  it is recommended that implementations
234         *      restrict external connections by default, though this may cause problems for applications
235         *      that process XML/XSD/XSL with external references.
236         * </blockquote>
237         *
238         * <p>
239         * <b>Granting all access:</b>  the keyword "all" grants permission to all protocols.
240         *
241         * <p>
242         * <b>System Property:</b> The value of this property can be set or overridden by
243         * system property {@code javax.xml.accessExternalDTD}.
244         *
245         *
246         * <p>
247         * <b>jaxp.properties:</b> This configuration file is in standard
248         * {@link java.util.Properties} format and typically located in the {@code conf}
249         * directory of the Java installation. If the file exists and the system
250         * property is specified, its value will be used to override the default
251         * of the property.
252         *
253         *
254         * @since 1.7
255         */
256        public static final String ACCESS_EXTERNAL_DTD = "http://javax.xml.XMLConstants/property/accessExternalDTD";
257
258        /**
259         * <p>Property: accessExternalSchema</p>
260         *
261         * <p>
262         * Restrict access to the protocols specified for external reference set by the
263         * schemaLocation attribute, Import and Include element. If access is denied
264         * due to the restriction of this property, a runtime exception that is specific
265         * to the context is thrown. In the case of {@link javax.xml.validation.SchemaFactory}
266         * for example, org.xml.sax.SAXException is thrown.
267         *
268         * <p>
269         * <b>Value:</b> a list of protocols separated by comma. A protocol is the scheme portion of a
270         * {@link java.net.URI}, or in the case of the JAR protocol, "jar" plus the scheme portion
271         * separated by colon.
272         * A scheme is defined as:
273         *
274         * <blockquote>
275         * scheme = alpha *( alpha | digit | "+" | "-" | "." )<br>
276         * where alpha = a-z and A-Z.<br><br>
277         *
278         * And the JAR protocol:<br>
279         *
280         * jar[:scheme]<br><br>
281         *
282         * Protocols including the keyword "jar" are case-insensitive. Any whitespaces as defined by
283         * {@link java.lang.Character#isSpaceChar } in the value will be ignored.
284         * Examples of protocols are file, http, jar:file.
285         *
286         * </blockquote>
287         *
288         * <p>
289         * <b>Default value:</b> The default value is implementation specific and therefore not specified.
290         * The following options are provided for consideration:
291         * <blockquote>
292         * <UL>
293         *     <LI>an empty string to deny all access to external references;</LI>
294         *     <LI>a specific protocol, such as file, to give permission to only the protocol;</LI>
295         *     <LI>the keyword "all" to grant  permission to all protocols.</LI>
296         * </UL><br>
297         *      When FEATURE_SECURE_PROCESSING is enabled,  it is recommended that implementations
298         *      restrict external connections by default, though this may cause problems for applications
299         *      that process XML/XSD/XSL with external references.
300         * </blockquote>
301         *
302         * <p>
303         * <b>Granting all access:</b>  the keyword "all" grants permission to all protocols.
304         *
305         * <p>
306         * <b>System Property:</b> The value of this property can be set or overridden by
307         * system property {@code javax.xml.accessExternalSchema}
308         *
309         * <p>
310         * <b>jaxp.properties:</b> This configuration file is in standard
311         * {@link java.util.Properties} format and typically located in the {@code conf}
312         * directory of the Java installation. If the file exists and the system
313         * property is specified, its value will be used to override the default
314         * of the property.
315         *
316         * @since 1.7
317         */
318        public static final String ACCESS_EXTERNAL_SCHEMA = "http://javax.xml.XMLConstants/property/accessExternalSchema";
319
320        /**
321         * Property: accessExternalStylesheet
322         *
323         * <p>
324         * Restrict access to the protocols specified for external references set by the
325         * stylesheet processing instruction, Import and Include element, and document function.
326         * If access is denied due to the restriction of this property, a runtime exception
327         * that is specific to the context is thrown. In the case of constructing new
328         * {@link javax.xml.transform.Transformer} for example,
329         * {@link javax.xml.transform.TransformerConfigurationException}
330         * will be thrown by the {@link javax.xml.transform.TransformerFactory}.
331         *
332         * <p>
333         * <b>Value:</b> a list of protocols separated by comma. A protocol is the scheme portion of a
334         * {@link java.net.URI}, or in the case of the JAR protocol, "jar" plus the scheme portion
335         * separated by colon.
336         * A scheme is defined as:
337         *
338         * <blockquote>
339         * scheme = alpha *( alpha | digit | "+" | "-" | "." )<br>
340         * where alpha = a-z and A-Z.<br><br>
341         *
342         * And the JAR protocol:<br>
343         *
344         * jar[:scheme]<br><br>
345         *
346         * Protocols including the keyword "jar" are case-insensitive. Any whitespaces as defined by
347         * {@link java.lang.Character#isSpaceChar } in the value will be ignored.
348         * Examples of protocols are file, http, jar:file.
349         *
350         * </blockquote>
351         *
352         * <p>
353         * <b>Default value:</b> The default value is implementation specific and therefore not specified.
354         * The following options are provided for consideration:
355         * <blockquote>
356         * <UL>
357         *     <LI>an empty string to deny all access to external references;</LI>
358         *     <LI>a specific protocol, such as file, to give permission to only the protocol;</LI>
359         *     <LI>the keyword "all" to grant  permission to all protocols.</LI>
360         * </UL><br>
361         *      When FEATURE_SECURE_PROCESSING is enabled,  it is recommended that implementations
362         *      restrict external connections by default, though this may cause problems for applications
363         *      that process XML/XSD/XSL with external references.
364         * </blockquote>
365         *
366         * <p>
367         * <b>Granting all access:</b>  the keyword "all" grants permission to all protocols.
368         *
369         * <p>
370         * <b>System Property:</b> The value of this property can be set or overridden by
371         * system property {@code javax.xml.accessExternalStylesheet}
372         *
373         * <p>
374         * <b>jaxp.properties:</b> This configuration file is in standard
375         * {@link java.util.Properties} format and typically located in the {@code conf}
376         * directory of the Java installation. If the file exists and the system
377         * property is specified, its value will be used to override the default
378         * of the property.
379         *
380         * @since 1.7
381         */
382        public static final String ACCESS_EXTERNAL_STYLESHEET = "http://javax.xml.XMLConstants/property/accessExternalStylesheet";
383
384
385        /**
386         * Feature: useCatalog
387         *
388         * <p>
389         * Instructs XML processors to use XML Catalogs to resolve entity references.
390         * Catalogs may be set through JAXP factories, system properties, or
391         * jaxp.properties by using the {@code javax.xml.catalog.files} property
392         * defined in {@link javax.xml.catalog.CatalogFeatures}.
393         * The following code enables Catalog on SAX parser:
394         * <pre>{@code
395         *      SAXParserFactory spf = SAXParserFactory.newInstance();
396         *      spf.setFeature(XMLConstants.USE_CATALOG, true);
397         *      SAXParser parser = spf.newSAXParser();
398         *      parser.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), "catalog.xml");
399         * }</pre>
400         *
401         * <p>
402         * <b>Value:</b> a boolean. If the value is true, and a catalog is set,
403         * the XML parser will resolve external references using
404         * {@link javax.xml.catalog.CatalogResolver}. If the value is false,
405         * XML Catalog is ignored even if one is set. The default value is true.
406         *
407         * <p>
408         * <b>System Property:</b> The value of this property can be set or overridden by
409         * system property {@code javax.xml.useCatalog}
410         *
411         * <p>
412         * <b>jaxp.properties:</b> This configuration file is in standard
413         * {@link java.util.Properties} format and typically located in the {@code conf}
414         * directory of the Java installation. If the file exists and the system
415         * property is specified, its value will be used to override the default
416         * value of the property.
417         *
418         * @since 9
419         */
420        public static final String USE_CATALOG = "http://javax.xml.XMLConstants/feature/useCatalog";
421
422}
423