jaxp/src/java.xml/share/classes/javax/xml/XMLConstants.java
changeset 25868 686eef1e7a79
parent 25264 040625ce9b72
child 27574 2e8afdf5c6fb
equal deleted inserted replaced
25867:3d364c870c90 25868:686eef1e7a79
       
     1 /*
       
     2  * Copyright (c) 2003, 2013, 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  * @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 
       
    42 public final class XMLConstants {
       
    43 
       
    44     /**
       
    45      * <p>Private constructor to prevent instantiation.</p>
       
    46      */
       
    47         private XMLConstants() {
       
    48         }
       
    49 
       
    50     /**
       
    51      * <p>Namespace URI to use to represent that there is no Namespace.</p>
       
    52      *
       
    53      * <p>Defined by the Namespace specification to be "".</p>
       
    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      * <p>Prefix to use to represent the default XML Namespace.</p>
       
    62      *
       
    63      * <p>Defined by the XML specification to be "".</p>
       
    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      * <p>The official XML Namespace name URI.</p>
       
    73      *
       
    74      * <p>Defined by the XML specification to be
       
    75      * "{@code http://www.w3.org/XML/1998/namespace}".</p>
       
    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      * <p>The official XML Namespace prefix.</p>
       
    86      *
       
    87      * <p>Defined by the XML specification to be "{@code xml}".</p>
       
    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      * <p>The official XML attribute used for specifying XML Namespace
       
    97      * declarations, {@link #XMLNS_ATTRIBUTE
       
    98      * XMLConstants.XMLNS_ATTRIBUTE}, Namespace name URI.</p>
       
    99      *
       
   100      * <p>Defined by the XML specification to be
       
   101      * "{@code http://www.w3.org/2000/xmlns/}".</p>
       
   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      * <p>The official XML attribute used for specifying XML Namespace
       
   115      * declarations.</p>
       
   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}".</p>
       
   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      * <p>W3C XML Schema Namespace URI.</p>
       
   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      * <p>W3C XML Schema Instance Namespace URI.</p>
       
   142      *
       
   143      * <p>Defined to be "{@code http://www.w3.org/2001/XMLSchema-instance}".</p>
       
   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          * <p>W3C XPath Datatype Namespace URI.</p>
       
   155          *
       
   156          * <p>Defined to be "{@code http://www.w3.org/2003/11/xpath-datatypes}".</p>
       
   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      * <p>XML Document Type Declaration Namespace URI as an arbitrary value.</p>
       
   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          * <p>RELAX NG Namespace URI.</p>
       
   171          *
       
   172          * <p>Defined to be "{@code http://relaxng.org/ns/structure/1.0}".</p>
       
   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          * <p>Feature for secure processing.</p>
       
   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          * <p>Property: accessExternalDTD</p>
       
   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          * </p>
       
   204          *
       
   205          * <p>
       
   206          * <b>Value: </b> a list of protocols separated by comma. A protocol is the scheme portion of a
       
   207          * {@link java.net.URI}, or in the case of the JAR protocol, "jar" plus the scheme portion
       
   208          * separated by colon.
       
   209          * A scheme is defined as:
       
   210          *
       
   211          * <blockquote>
       
   212          * scheme = alpha *( alpha | digit | "+" | "-" | "." )<br>
       
   213          * where alpha = a-z and A-Z.<br><br>
       
   214          *
       
   215          * And the JAR protocol:<br>
       
   216          *
       
   217          * jar[:scheme]<br><br>
       
   218          *
       
   219          * Protocols including the keyword "jar" are case-insensitive. Any whitespaces as defined by
       
   220          * {@link java.lang.Character#isSpaceChar } in the value will be ignored.
       
   221          * Examples of protocols are file, http, jar:file.
       
   222          *
       
   223          * </blockquote>
       
   224          *</p>
       
   225          *
       
   226          *<p>
       
   227          * <b>Default value:</b> The default value is implementation specific and therefore not specified.
       
   228          * The following options are provided for consideration:
       
   229          * <blockquote>
       
   230          * <UL>
       
   231          *     <LI>an empty string to deny all access to external references;</LI>
       
   232          *     <LI>a specific protocol, such as file, to give permission to only the protocol;</LI>
       
   233          *     <LI>the keyword "all" to grant  permission to all protocols.</LI>
       
   234          *</UL><br>
       
   235          *      When FEATURE_SECURE_PROCESSING is enabled,  it is recommended that implementations
       
   236          *      restrict external connections by default, though this may cause problems for applications
       
   237          *      that process XML/XSD/XSL with external references.
       
   238          * </blockquote>
       
   239          * </p>
       
   240          *
       
   241          * <p>
       
   242          * <b>Granting all access:</b>  the keyword "all" grants permission to all protocols.
       
   243          * </p>
       
   244          * <p>
       
   245          * <b>System Property:</b> The value of this property can be set or overridden by
       
   246          * system property {@code javax.xml.accessExternalDTD}.
       
   247          * </p>
       
   248          *
       
   249          * <p>
       
   250          * <b>${JAVA_HOME}/lib/jaxp.properties:</b> This configuration file is in standard
       
   251          * {@link java.util.Properties} format. If the file exists and the system property is specified,
       
   252          * its value will be used to override the default of the property.
       
   253          * </p>
       
   254          *
       
   255          * <p>
       
   256          *
       
   257          * </p>
       
   258          * @since 1.7
       
   259          */
       
   260         public static final String ACCESS_EXTERNAL_DTD = "http://javax.xml.XMLConstants/property/accessExternalDTD";
       
   261 
       
   262         /**
       
   263          * <p>Property: accessExternalSchema</p>
       
   264          *
       
   265          * <p>
       
   266          * Restrict access to the protocols specified for external reference set by the
       
   267          * schemaLocation attribute, Import and Include element. If access is denied
       
   268          * due to the restriction of this property, a runtime exception that is specific
       
   269          * to the context is thrown. In the case of {@link javax.xml.validation.SchemaFactory}
       
   270          * for example, org.xml.sax.SAXException is thrown.
       
   271          * </p>
       
   272          * <p>
       
   273          * <b>Value:</b> a list of protocols separated by comma. A protocol is the scheme portion of a
       
   274          * {@link java.net.URI}, or in the case of the JAR protocol, "jar" plus the scheme portion
       
   275          * separated by colon.
       
   276          * A scheme is defined as:
       
   277          *
       
   278          * <blockquote>
       
   279          * scheme = alpha *( alpha | digit | "+" | "-" | "." )<br>
       
   280          * where alpha = a-z and A-Z.<br><br>
       
   281          *
       
   282          * And the JAR protocol:<br>
       
   283          *
       
   284          * jar[:scheme]<br><br>
       
   285          *
       
   286          * Protocols including the keyword "jar" are case-insensitive. Any whitespaces as defined by
       
   287          * {@link java.lang.Character#isSpaceChar } in the value will be ignored.
       
   288          * Examples of protocols are file, http, jar:file.
       
   289          *
       
   290          * </blockquote>
       
   291          *</p>
       
   292          *
       
   293          *<p>
       
   294          * <b>Default value:</b> The default value is implementation specific and therefore not specified.
       
   295          * The following options are provided for consideration:
       
   296          * <blockquote>
       
   297          * <UL>
       
   298          *     <LI>an empty string to deny all access to external references;</LI>
       
   299          *     <LI>a specific protocol, such as file, to give permission to only the protocol;</LI>
       
   300          *     <LI>the keyword "all" to grant  permission to all protocols.</LI>
       
   301          *</UL><br>
       
   302          *      When FEATURE_SECURE_PROCESSING is enabled,  it is recommended that implementations
       
   303          *      restrict external connections by default, though this may cause problems for applications
       
   304          *      that process XML/XSD/XSL with external references.
       
   305          * </blockquote>
       
   306          * </p>
       
   307          * <p>
       
   308          * <b>Granting all access:</b>  the keyword "all" grants permission to all protocols.
       
   309          * </p>
       
   310          *
       
   311          * <p>
       
   312          * <b>System Property:</b> The value of this property can be set or overridden by
       
   313          * system property {@code javax.xml.accessExternalSchema}
       
   314          * </p>
       
   315          *
       
   316          * <p>
       
   317          * <b>${JAVA_HOME}/lib/jaxp.properties:</b> This configuration file is in standard
       
   318          * java.util.Properties format. If the file exists and the system property is specified,
       
   319          * its value will be used to override the default of the property.
       
   320          *
       
   321          * @since 1.7
       
   322          * </p>
       
   323          */
       
   324         public static final String ACCESS_EXTERNAL_SCHEMA = "http://javax.xml.XMLConstants/property/accessExternalSchema";
       
   325 
       
   326         /**
       
   327          * <p>Property: accessExternalStylesheet</p>
       
   328          *
       
   329          * <p>
       
   330          * Restrict access to the protocols specified for external references set by the
       
   331          * stylesheet processing instruction, Import and Include element, and document function.
       
   332          * If access is denied due to the restriction of this property, a runtime exception
       
   333          * that is specific to the context is thrown. In the case of constructing new
       
   334          * {@link javax.xml.transform.Transformer} for example,
       
   335          * {@link javax.xml.transform.TransformerConfigurationException}
       
   336          * will be thrown by the {@link javax.xml.transform.TransformerFactory}.
       
   337          * </p>
       
   338          * <p>
       
   339          * <b>Value:</b> a list of protocols separated by comma. A protocol is the scheme portion of a
       
   340          * {@link java.net.URI}, or in the case of the JAR protocol, "jar" plus the scheme portion
       
   341          * separated by colon.
       
   342          * A scheme is defined as:
       
   343          *
       
   344          * <blockquote>
       
   345          * scheme = alpha *( alpha | digit | "+" | "-" | "." )<br>
       
   346          * where alpha = a-z and A-Z.<br><br>
       
   347          *
       
   348          * And the JAR protocol:<br>
       
   349          *
       
   350          * jar[:scheme]<br><br>
       
   351          *
       
   352          * Protocols including the keyword "jar" are case-insensitive. Any whitespaces as defined by
       
   353          * {@link java.lang.Character#isSpaceChar } in the value will be ignored.
       
   354          * Examples of protocols are file, http, jar:file.
       
   355          *
       
   356          * </blockquote>
       
   357          *</p>
       
   358          *
       
   359          *<p>
       
   360          * <b>Default value:</b> The default value is implementation specific and therefore not specified.
       
   361          * The following options are provided for consideration:
       
   362          * <blockquote>
       
   363          * <UL>
       
   364          *     <LI>an empty string to deny all access to external references;</LI>
       
   365          *     <LI>a specific protocol, such as file, to give permission to only the protocol;</LI>
       
   366          *     <LI>the keyword "all" to grant  permission to all protocols.</LI>
       
   367          *</UL><br>
       
   368          *      When FEATURE_SECURE_PROCESSING is enabled,  it is recommended that implementations
       
   369          *      restrict external connections by default, though this may cause problems for applications
       
   370          *      that process XML/XSD/XSL with external references.
       
   371          * </blockquote>
       
   372          * </p>
       
   373          * <p>
       
   374          * <b>Granting all access:</b>  the keyword "all" grants permission to all protocols.
       
   375          * </p>
       
   376          *
       
   377          * <p>
       
   378          * <b>System Property:</b> The value of this property can be set or overridden by
       
   379          * system property {@code javax.xml.accessExternalStylesheet}
       
   380          * </p>
       
   381          *
       
   382          * <p>
       
   383          * <b>${JAVA_HOME}/lib/jaxp.properties: </b> This configuration file is in standard
       
   384          * java.util.Properties format. If the file exists and the system property is specified,
       
   385          * its value will be used to override the default of the property.
       
   386          *
       
   387          * @since 1.7
       
   388          */
       
   389         public static final String ACCESS_EXTERNAL_STYLESHEET = "http://javax.xml.XMLConstants/property/accessExternalStylesheet";
       
   390 
       
   391 }