1 /*
   2  * Copyright (c) 2003, 2005, 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 
  26 package javax.xml;
  27 
  28 /**
  29  * <p>Utility class to contain basic XML values as constants.</p>
  30  *
  31  * @author <a href="mailto:Jeff.Suttor@Sun.com">Jeff Suttor</a>
  32  * @version $Revision: 1.8 $, $Date: 2010/05/25 16:19:45 $
  33  * @see <a href="http://www.w3.org/TR/xml11/">Extensible Markup Language (XML) 1.1</a>
  34  * @see <a href="http://www.w3.org/TR/REC-xml">Extensible Markup Language (XML) 1.0 (Second Edition)</a>
  35  * @see <a href="http://www.w3.org/XML/xml-V10-2e-errata">XML 1.0 Second Edition Specification Errata</a>
  36  * @see <a href="http://www.w3.org/TR/xml-names11/">Namespaces in XML 1.1</a>
  37  * @see <a href="http://www.w3.org/TR/REC-xml-names">Namespaces in XML</a>
  38  * @see <a href="http://www.w3.org/XML/xml-names-19990114-errata">Namespaces in XML Errata</a>
  39  * @see <a href="http://www.w3.org/TR/xmlschema-1/">XML Schema Part 1: Structures</a>
  40  * @since 1.5
  41  **/
  42 
  43 public final class XMLConstants {
  44 
  45     /**
  46      * <p>Private constructor to prevent instantiation.</p>
  47      */
  48         private XMLConstants() {
  49         }
  50 
  51     /**
  52      * <p>Namespace URI to use to represent that there is no Namespace.</p>
  53      *
  54      * <p>Defined by the Namespace specification to be "".</p>
  55      *
  56      * @see <a href="http://www.w3.org/TR/REC-xml-names/#defaulting">
  57      * Namespaces in XML, 5.2 Namespace Defaulting</a>
  58      */
  59     public static final String NULL_NS_URI = "";
  60 
  61     /**
  62      * <p>Prefix to use to represent the default XML Namespace.</p>
  63      *
  64      * <p>Defined by the XML specification to be "".</p>
  65      *
  66      * @see <a
  67      * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">
  68      * Namespaces in XML, 3. Qualified Names</a>
  69      */
  70     public static final String DEFAULT_NS_PREFIX = "";
  71 
  72     /**
  73      * <p>The official XML Namespace name URI.</p>
  74      *
  75      * <p>Defined by the XML specification to be
  76      * "{@code http://www.w3.org/XML/1998/namespace}".</p>
  77      *
  78      * @see <a
  79      * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">
  80      * Namespaces in XML, 3. Qualified Names</a>
  81      */
  82     public static final String XML_NS_URI =
  83         "http://www.w3.org/XML/1998/namespace";
  84 
  85     /**
  86      * <p>The official XML Namespace prefix.</p>
  87      *
  88      * <p>Defined by the XML specification to be "{@code xml}".</p>
  89      *
  90      * @see <a
  91      * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">
  92      * Namespaces in XML, 3. Qualified Names<</a>
  93      */
  94     public static final String XML_NS_PREFIX = "xml";
  95 
  96     /**
  97      * <p>The official XML attribute used for specifying XML Namespace
  98      * declarations, {@link #XMLNS_ATTRIBUTE
  99      * XMLConstants.XMLNS_ATTRIBUTE}, Namespace name URI.</p>
 100      *
 101      * <p>Defined by the XML specification to be
 102      * "{@code http://www.w3.org/2000/xmlns/}".</p>
 103      *
 104      * @see <a
 105      * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">
 106      * Namespaces in XML, 3. Qualified Names</a>
 107      * @see <a
 108      * href="http://www.w3.org/XML/xml-names-19990114-errata">
 109      * Namespaces in XML Errata</a>
 110      */
 111     public static final String XMLNS_ATTRIBUTE_NS_URI =
 112         "http://www.w3.org/2000/xmlns/";
 113 
 114     /**
 115      * <p>The official XML attribute used for specifying XML Namespace
 116      * declarations.</p>
 117      *
 118      * <p>It is <strong><em>NOT</em></strong> valid to use as a
 119      * prefix.  Defined by the XML specification to be
 120      * "{@code xmlns}".</p>
 121      *
 122      * @see <a
 123      * href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">
 124      * Namespaces in XML, 3. Qualified Names</a>
 125      */
 126     public static final String XMLNS_ATTRIBUTE = "xmlns";
 127 
 128     /**
 129      * <p>W3C XML Schema Namespace URI.</p>
 130      *
 131      * <p>Defined to be "{@code http://www.w3.org/2001/XMLSchema}".
 132      *
 133      * @see <a href=
 134      *  "http://www.w3.org/TR/xmlschema-1/#Instance_Document_Constructions">
 135      *  XML Schema Part 1:
 136      *  Structures, 2.6 Schema-Related Markup in Documents Being Validated</a>
 137      */
 138     public static final String W3C_XML_SCHEMA_NS_URI =
 139         "http://www.w3.org/2001/XMLSchema";
 140 
 141     /**
 142      * <p>W3C XML Schema Instance Namespace URI.</p>
 143      *
 144      * <p>Defined to be "{@code http://www.w3.org/2001/XMLSchema-instance}".</p>
 145      *
 146      * @see <a href=
 147      *  "http://www.w3.org/TR/xmlschema-1/#Instance_Document_Constructions">
 148      *  XML Schema Part 1:
 149      *  Structures, 2.6 Schema-Related Markup in Documents Being Validated</a>
 150      */
 151     public static final String W3C_XML_SCHEMA_INSTANCE_NS_URI =
 152         "http://www.w3.org/2001/XMLSchema-instance";
 153 
 154         /**
 155          * <p>W3C XPath Datatype Namespace URI.</p>
 156          *
 157          * <p>Defined to be "{@code http://www.w3.org/2003/11/xpath-datatypes}".</p>
 158          *
 159          * @see <a href="http://www.w3.org/TR/xpath-datamodel">XQuery 1.0 and XPath 2.0 Data Model</a>
 160          */
 161         public static final String W3C_XPATH_DATATYPE_NS_URI = "http://www.w3.org/2003/11/xpath-datatypes";
 162 
 163     /**
 164      * <p>XML Document Type Declaration Namespace URI as an arbitrary value.</p>
 165      *
 166      * <p>Since not formally defined by any existing standard, arbitrarily define to be "{@code http://www.w3.org/TR/REC-xml}".
 167      */
 168     public static final String XML_DTD_NS_URI = "http://www.w3.org/TR/REC-xml";
 169 
 170         /**
 171          * <p>RELAX NG Namespace URI.</p>
 172          *
 173          * <p>Defined to be "{@code http://relaxng.org/ns/structure/1.0}".</p>
 174          *
 175          * @see <a href="http://relaxng.org/spec-20011203.html">RELAX NG Specification</a>
 176          */
 177         public static final String RELAXNG_NS_URI = "http://relaxng.org/ns/structure/1.0";
 178 
 179         /**
 180          * <p>Feature for secure processing.</p>
 181          *
 182          * <ul>
 183          *   <li>
 184          *     {@code true} instructs the implementation to process XML securely.
 185          *     This may set limits on XML constructs to avoid conditions such as denial of service attacks.
 186          *   </li>
 187          *   <li>
 188          *     {@code false} instructs the implementation to process XML in accordance with the XML specifications
 189          *     ignoring security issues such as limits on XML constructs to avoid conditions such as denial of service attacks.
 190          *   </li>
 191          * </ul>
 192          */
 193         public static final String FEATURE_SECURE_PROCESSING = "http://javax.xml.XMLConstants/feature/secure-processing";
 194 
 195 
 196         /**
 197          * <p>Property: accessExternalDTD</p>
 198          *
 199          * <p>
 200          * Restrict access to external DTDs and external Entity References to the protocols specified.
 201          * If access is denied due to the restriction of this property, a runtime exception that
 202          * is specific to the context is thrown. In the case of {@link javax.xml.parsers.SAXParser}
 203          * for example, {@link org.xml.sax.SAXException} is thrown.
 204          * </p>
 205          *
 206          * <p>
 207          * <b>Value: </b> a list of protocols separated by comma. A protocol is the scheme portion of a
 208          * {@link java.net.URI}, or in the case of the JAR protocol, "jar" plus the scheme portion
 209          * separated by colon.
 210          * A scheme is defined as:
 211          *
 212          * <blockquote>
 213          * scheme = alpha *( alpha | digit | "+" | "-" | "." )<br>
 214          * where alpha = a-z and A-Z.<br><br>
 215          *
 216          * And the JAR protocol:<br>
 217          *
 218          * jar[:scheme]<br><br>
 219          *
 220          * Protocols including the keyword "jar" are case-insensitive. Any whitespaces as defined by
 221          * {@link java.lang.Character#isSpaceChar } in the value will be ignored.
 222          * Examples of protocols are file, http, jar:file.
 223          *
 224          * </blockquote>
 225          *</p>
 226          *
 227          *<p>
 228          * <b>Default value:</b> The default value is implementation specific and therefore not specified.
 229          * The following options are provided for consideration:
 230          * <blockquote>
 231          * <UL>
 232          *     <LI>an empty string to deny all access to external references;</LI>
 233          *     <LI>a specific protocol, such as file, to give permission to only the protocol;</LI>
 234          *     <LI>the keyword "all" to grant  permission to all protocols.</LI>
 235          *</UL><br>
 236          *      When FEATURE_SECURE_PROCESSING is enabled,  it is recommended that implementations
 237          *      restrict external connections by default, though this may cause problems for applications
 238          *      that process XML/XSD/XSL with external references.
 239          * </blockquote>
 240          * </p>
 241          *
 242          * <p>
 243          * <b>Granting all access:</b>  the keyword "all" grants permission to all protocols.
 244          * </p>
 245          * <p>
 246          * <b>System Property:</b> The value of this property can be set or overridden by
 247          * system property {@code javax.xml.accessExternalDTD}.
 248          * </p>
 249          *
 250          * <p>
 251          * <b>${JAVA_HOME}/lib/jaxp.properties:</b> This configuration file is in standard
 252          * {@link java.util.Properties} format. If the file exists and the system property is specified,
 253          * its value will be used to override the default of the property.
 254          * </p>
 255          *
 256          * <p>
 257          *
 258          * </p>
 259          * @since 1.7
 260          */
 261         public static final String ACCESS_EXTERNAL_DTD = "http://javax.xml.XMLConstants/property/accessExternalDTD";
 262 
 263         /**
 264          * <p>Property: accessExternalSchema</p>
 265          *
 266          * <p>
 267          * Restrict access to the protocols specified for external reference set by the
 268          * schemaLocation attribute, Import and Include element. If access is denied
 269          * due to the restriction of this property, a runtime exception that is specific
 270          * to the context is thrown. In the case of {@link javax.xml.validation.SchemaFactory}
 271          * for example, org.xml.sax.SAXException is thrown.
 272          * </p>
 273          * <p>
 274          * <b>Value:</b> a list of protocols separated by comma. A protocol is the scheme portion of a
 275          * {@link java.net.URI}, or in the case of the JAR protocol, "jar" plus the scheme portion
 276          * separated by colon.
 277          * A scheme is defined as:
 278          *
 279          * <blockquote>
 280          * scheme = alpha *( alpha | digit | "+" | "-" | "." )<br>
 281          * where alpha = a-z and A-Z.<br><br>
 282          *
 283          * And the JAR protocol:<br>
 284          *
 285          * jar[:scheme]<br><br>
 286          *
 287          * Protocols including the keyword "jar" are case-insensitive. Any whitespaces as defined by
 288          * {@link java.lang.Character#isSpaceChar } in the value will be ignored.
 289          * Examples of protocols are file, http, jar:file.
 290          *
 291          * </blockquote>
 292          *</p>
 293          *
 294          *<p>
 295          * <b>Default value:</b> The default value is implementation specific and therefore not specified.
 296          * The following options are provided for consideration:
 297          * <blockquote>
 298          * <UL>
 299          *     <LI>an empty string to deny all access to external references;</LI>
 300          *     <LI>a specific protocol, such as file, to give permission to only the protocol;</LI>
 301          *     <LI>the keyword "all" to grant  permission to all protocols.</LI>
 302          *</UL><br>
 303          *      When FEATURE_SECURE_PROCESSING is enabled,  it is recommended that implementations
 304          *      restrict external connections by default, though this may cause problems for applications
 305          *      that process XML/XSD/XSL with external references.
 306          * </blockquote>
 307          * </p>
 308          * <p>
 309          * <b>Granting all access:</b>  the keyword "all" grants permission to all protocols.
 310          * </p>
 311          *
 312          * <p>
 313          * <b>System Property:</b> The value of this property can be set or overridden by
 314          * system property {@code javax.xml.accessExternalSchema}
 315          * </p>
 316          *
 317          * <p>
 318          * <b>${JAVA_HOME}/lib/jaxp.properties:</b> This configuration file is in standard
 319          * java.util.Properties format. If the file exists and the system property is specified,
 320          * its value will be used to override the default of the property.
 321          *
 322          * @since 1.7
 323          * </p>
 324          */
 325         public static final String ACCESS_EXTERNAL_SCHEMA = "http://javax.xml.XMLConstants/property/accessExternalSchema";
 326 
 327         /**
 328          * <p>Property: accessExternalStylesheet</p>
 329          *
 330          * <p>
 331          * Restrict access to the protocols specified for external references set by the
 332          * stylesheet processing instruction, Import and Include element, and document function.
 333          * If access is denied due to the restriction of this property, a runtime exception
 334          * that is specific to the context is thrown. In the case of constructing new
 335          * {@link javax.xml.transform.Transformer} for example,
 336          * {@link javax.xml.transform.TransformerConfigurationException}
 337          * will be thrown by the {@link javax.xml.transform.TransformerFactory}.
 338          * </p>
 339          * <p>
 340          * <b>Value:</b> a list of protocols separated by comma. A protocol is the scheme portion of a
 341          * {@link java.net.URI}, or in the case of the JAR protocol, "jar" plus the scheme portion
 342          * separated by colon.
 343          * A scheme is defined as:
 344          *
 345          * <blockquote>
 346          * scheme = alpha *( alpha | digit | "+" | "-" | "." )<br>
 347          * where alpha = a-z and A-Z.<br><br>
 348          *
 349          * And the JAR protocol:<br>
 350          *
 351          * jar[:scheme]<br><br>
 352          *
 353          * Protocols including the keyword "jar" are case-insensitive. Any whitespaces as defined by
 354          * {@link java.lang.Character#isSpaceChar } in the value will be ignored.
 355          * Examples of protocols are file, http, jar:file.
 356          *
 357          * </blockquote>
 358          *</p>
 359          *
 360          *<p>
 361          * <b>Default value:</b> The default value is implementation specific and therefore not specified.
 362          * The following options are provided for consideration:
 363          * <blockquote>
 364          * <UL>
 365          *     <LI>an empty string to deny all access to external references;</LI>
 366          *     <LI>a specific protocol, such as file, to give permission to only the protocol;</LI>
 367          *     <LI>the keyword "all" to grant  permission to all protocols.</LI>
 368          *</UL><br>
 369          *      When FEATURE_SECURE_PROCESSING is enabled,  it is recommended that implementations
 370          *      restrict external connections by default, though this may cause problems for applications
 371          *      that process XML/XSD/XSL with external references.
 372          * </blockquote>
 373          * </p>
 374          * <p>
 375          * <b>Granting all access:</b>  the keyword "all" grants permission to all protocols.
 376          * </p>
 377          *
 378          * <p>
 379          * <b>System Property:</b> The value of this property can be set or overridden by
 380          * system property {@code javax.xml.accessExternalStylesheet}
 381          * </p>
 382          *
 383          * <p>
 384          * <b>${JAVA_HOME}/lib/jaxp.properties: </b> This configuration file is in standard
 385          * java.util.Properties format. If the file exists and the system property is specified,
 386          * its value will be used to override the default of the property.
 387          *
 388          * @since 1.7
 389          */
 390         public static final String ACCESS_EXTERNAL_STYLESHEET = "http://javax.xml.XMLConstants/property/accessExternalStylesheet";
 391 
 392 }