Path: blob/master/src/java.xml/share/classes/javax/xml/XMLConstants.java
40948 views
/*1* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.xml;2627/**28* <p>Utility class to contain basic XML values as constants.29*30* @author Jeff Suttor31* @see <a href="http://www.w3.org/TR/xml11/">Extensible Markup Language (XML) 1.1</a>32* @see <a href="http://www.w3.org/TR/REC-xml">Extensible Markup Language (XML) 1.0 (Second Edition)</a>33* @see <a href="http://www.w3.org/XML/xml-V10-2e-errata">XML 1.0 Second Edition Specification Errata</a>34* @see <a href="http://www.w3.org/TR/xml-names11/">Namespaces in XML 1.1</a>35* @see <a href="http://www.w3.org/TR/REC-xml-names">Namespaces in XML</a>36* @see <a href="http://www.w3.org/TR/xmlschema-1/">XML Schema Part 1: Structures</a>37* @since 1.538**/3940public final class XMLConstants {4142/**43* Private constructor to prevent instantiation.44*/45private XMLConstants() {46}4748/**49* Namespace URI to use to represent that there is no Namespace.50*51* <p>Defined by the Namespace specification to be "".52*53* @see <a href="http://www.w3.org/TR/REC-xml-names/#defaulting">54* Namespaces in XML, 5.2 Namespace Defaulting</a>55*/56public static final String NULL_NS_URI = "";5758/**59* Prefix to use to represent the default XML Namespace.60*61* <p>Defined by the XML specification to be "".62*63* @see <a64* href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">65* Namespaces in XML, 3. Qualified Names</a>66*/67public static final String DEFAULT_NS_PREFIX = "";6869/**70* The official XML Namespace name URI.71*72* <p>Defined by the XML specification to be73* "{@code http://www.w3.org/XML/1998/namespace}".74*75* @see <a76* href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">77* Namespaces in XML, 3. Qualified Names</a>78*/79public static final String XML_NS_URI =80"http://www.w3.org/XML/1998/namespace";8182/**83* The official XML Namespace prefix.84*85* <p>Defined by the XML specification to be "{@code xml}".86*87* @see <a88* href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">89* Namespaces in XML, 3. Qualified Names</a>90*/91public static final String XML_NS_PREFIX = "xml";9293/**94* The official XML attribute used for specifying XML Namespace95* declarations, {@link #XMLNS_ATTRIBUTE96* XMLConstants.XMLNS_ATTRIBUTE}, Namespace name URI.97*98* <p>Defined by the XML specification to be99* "{@code http://www.w3.org/2000/xmlns/}".100*101* @see <a102* href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">103* Namespaces in XML, 3. Qualified Names</a>104*/105public static final String XMLNS_ATTRIBUTE_NS_URI =106"http://www.w3.org/2000/xmlns/";107108/**109* The official XML attribute used for specifying XML Namespace110* declarations.111*112* <p>It is <strong><em>NOT</em></strong> valid to use as a113* prefix. Defined by the XML specification to be114* "{@code xmlns}".115*116* @see <a117* href="http://www.w3.org/TR/REC-xml-names/#ns-qualnames">118* Namespaces in XML, 3. Qualified Names</a>119*/120public static final String XMLNS_ATTRIBUTE = "xmlns";121122/**123* W3C XML Schema Namespace URI.124*125* <p>Defined to be "{@code http://www.w3.org/2001/XMLSchema}".126*127* @see <a href=128* "http://www.w3.org/TR/xmlschema-1/#Instance_Document_Constructions">129* XML Schema Part 1:130* Structures, 2.6 Schema-Related Markup in Documents Being Validated</a>131*/132public static final String W3C_XML_SCHEMA_NS_URI =133"http://www.w3.org/2001/XMLSchema";134135/**136* W3C XML Schema Instance Namespace URI.137*138* <p>Defined to be "{@code http://www.w3.org/2001/XMLSchema-instance}".139*140* @see <a href=141* "http://www.w3.org/TR/xmlschema-1/#Instance_Document_Constructions">142* XML Schema Part 1:143* Structures, 2.6 Schema-Related Markup in Documents Being Validated</a>144*/145public static final String W3C_XML_SCHEMA_INSTANCE_NS_URI =146"http://www.w3.org/2001/XMLSchema-instance";147148/**149* W3C XPath Datatype Namespace URI.150*151* <p>Defined to be "{@code http://www.w3.org/2003/11/xpath-datatypes}".152*153* @see <a href="http://www.w3.org/TR/xpath-datamodel">XQuery 1.0 and XPath 2.0 Data Model</a>154*/155public static final String W3C_XPATH_DATATYPE_NS_URI = "http://www.w3.org/2003/11/xpath-datatypes";156157/**158* XML Document Type Declaration Namespace URI as an arbitrary value.159*160* <p>Since not formally defined by any existing standard, arbitrarily define to be "{@code http://www.w3.org/TR/REC-xml}".161*/162public static final String XML_DTD_NS_URI = "http://www.w3.org/TR/REC-xml";163164/**165* RELAX NG Namespace URI.166*167* <p>Defined to be "{@code http://relaxng.org/ns/structure/1.0}".168*169* @see <a href="http://relaxng.org/spec-20011203.html">RELAX NG Specification</a>170*/171public static final String RELAXNG_NS_URI = "http://relaxng.org/ns/structure/1.0";172173/**174* Feature for secure processing.175*176* <ul>177* <li>178* {@code true} instructs the implementation to process XML securely.179* This may set limits on XML constructs to avoid conditions such as denial of service attacks.180* </li>181* <li>182* {@code false} instructs the implementation to process XML in accordance with the XML specifications183* ignoring security issues such as limits on XML constructs to avoid conditions such as denial of service attacks.184* </li>185* </ul>186*/187public static final String FEATURE_SECURE_PROCESSING = "http://javax.xml.XMLConstants/feature/secure-processing";188189190/**191* Property: accessExternalDTD192*193* <p>194* Restrict access to external DTDs and external Entity References to the protocols specified.195* If access is denied due to the restriction of this property, a runtime exception that196* is specific to the context is thrown. In the case of {@link javax.xml.parsers.SAXParser}197* for example, {@link org.xml.sax.SAXException} is thrown.198*199* <p>200* <b>Value: </b> a list of protocols separated by comma. A protocol is the scheme portion of a201* {@link java.net.URI}, or in the case of the JAR protocol, "jar" plus the scheme portion202* separated by colon.203* A scheme is defined as:204*205* <blockquote>206* scheme = alpha *( alpha | digit | "+" | "-" | "." )<br>207* where alpha = a-z and A-Z.<br><br>208*209* And the JAR protocol:<br>210*211* jar[:scheme]<br><br>212*213* Protocols including the keyword "jar" are case-insensitive. Any whitespaces as defined by214* {@link java.lang.Character#isSpaceChar } in the value will be ignored.215* Examples of protocols are file, http, jar:file.216*217* </blockquote>218*219*<p>220* <b>Default value:</b> The default value is implementation specific and therefore not specified.221* The following options are provided for consideration:222* <blockquote>223* <UL>224* <LI>an empty string to deny all access to external references;</LI>225* <LI>a specific protocol, such as file, to give permission to only the protocol;</LI>226* <LI>the keyword "all" to grant permission to all protocols.</LI>227* </UL><br>228* When FEATURE_SECURE_PROCESSING is enabled, it is recommended that implementations229* restrict external connections by default, though this may cause problems for applications230* that process XML/XSD/XSL with external references.231* </blockquote>232*233* <p>234* <b>Granting all access:</b> the keyword "all" grants permission to all protocols.235*236* <p>237* <b>System Property:</b> The value of this property can be set or overridden by238* system property {@code javax.xml.accessExternalDTD}.239*240*241* <p>242* <b>jaxp.properties:</b> This configuration file is in standard243* {@link java.util.Properties} format and typically located in the {@code conf}244* directory of the Java installation. If the file exists and the system245* property is specified, its value will be used to override the default246* of the property.247*248*249* @since 1.7250*/251public static final String ACCESS_EXTERNAL_DTD = "http://javax.xml.XMLConstants/property/accessExternalDTD";252253/**254* <p>Property: accessExternalSchema</p>255*256* <p>257* Restrict access to the protocols specified for external reference set by the258* schemaLocation attribute, Import and Include element. If access is denied259* due to the restriction of this property, a runtime exception that is specific260* to the context is thrown. In the case of {@link javax.xml.validation.SchemaFactory}261* for example, org.xml.sax.SAXException is thrown.262*263* <p>264* <b>Value:</b> a list of protocols separated by comma. A protocol is the scheme portion of a265* {@link java.net.URI}, or in the case of the JAR protocol, "jar" plus the scheme portion266* separated by colon.267* A scheme is defined as:268*269* <blockquote>270* scheme = alpha *( alpha | digit | "+" | "-" | "." )<br>271* where alpha = a-z and A-Z.<br><br>272*273* And the JAR protocol:<br>274*275* jar[:scheme]<br><br>276*277* Protocols including the keyword "jar" are case-insensitive. Any whitespaces as defined by278* {@link java.lang.Character#isSpaceChar } in the value will be ignored.279* Examples of protocols are file, http, jar:file.280*281* </blockquote>282*283* <p>284* <b>Default value:</b> The default value is implementation specific and therefore not specified.285* The following options are provided for consideration:286* <blockquote>287* <UL>288* <LI>an empty string to deny all access to external references;</LI>289* <LI>a specific protocol, such as file, to give permission to only the protocol;</LI>290* <LI>the keyword "all" to grant permission to all protocols.</LI>291* </UL><br>292* When FEATURE_SECURE_PROCESSING is enabled, it is recommended that implementations293* restrict external connections by default, though this may cause problems for applications294* that process XML/XSD/XSL with external references.295* </blockquote>296*297* <p>298* <b>Granting all access:</b> the keyword "all" grants permission to all protocols.299*300* <p>301* <b>System Property:</b> The value of this property can be set or overridden by302* system property {@code javax.xml.accessExternalSchema}303*304* <p>305* <b>jaxp.properties:</b> This configuration file is in standard306* {@link java.util.Properties} format and typically located in the {@code conf}307* directory of the Java installation. If the file exists and the system308* property is specified, its value will be used to override the default309* of the property.310*311* @since 1.7312*/313public static final String ACCESS_EXTERNAL_SCHEMA = "http://javax.xml.XMLConstants/property/accessExternalSchema";314315/**316* Property: accessExternalStylesheet317*318* <p>319* Restrict access to the protocols specified for external references set by the320* stylesheet processing instruction, Import and Include element, and document function.321* If access is denied due to the restriction of this property, a runtime exception322* that is specific to the context is thrown. In the case of constructing new323* {@link javax.xml.transform.Transformer} for example,324* {@link javax.xml.transform.TransformerConfigurationException}325* will be thrown by the {@link javax.xml.transform.TransformerFactory}.326*327* <p>328* <b>Value:</b> a list of protocols separated by comma. A protocol is the scheme portion of a329* {@link java.net.URI}, or in the case of the JAR protocol, "jar" plus the scheme portion330* separated by colon.331* A scheme is defined as:332*333* <blockquote>334* scheme = alpha *( alpha | digit | "+" | "-" | "." )<br>335* where alpha = a-z and A-Z.<br><br>336*337* And the JAR protocol:<br>338*339* jar[:scheme]<br><br>340*341* Protocols including the keyword "jar" are case-insensitive. Any whitespaces as defined by342* {@link java.lang.Character#isSpaceChar } in the value will be ignored.343* Examples of protocols are file, http, jar:file.344*345* </blockquote>346*347* <p>348* <b>Default value:</b> The default value is implementation specific and therefore not specified.349* The following options are provided for consideration:350* <blockquote>351* <UL>352* <LI>an empty string to deny all access to external references;</LI>353* <LI>a specific protocol, such as file, to give permission to only the protocol;</LI>354* <LI>the keyword "all" to grant permission to all protocols.</LI>355* </UL><br>356* When FEATURE_SECURE_PROCESSING is enabled, it is recommended that implementations357* restrict external connections by default, though this may cause problems for applications358* that process XML/XSD/XSL with external references.359* </blockquote>360*361* <p>362* <b>Granting all access:</b> the keyword "all" grants permission to all protocols.363*364* <p>365* <b>System Property:</b> The value of this property can be set or overridden by366* system property {@code javax.xml.accessExternalStylesheet}367*368* <p>369* <b>jaxp.properties:</b> This configuration file is in standard370* {@link java.util.Properties} format and typically located in the {@code conf}371* directory of the Java installation. If the file exists and the system372* property is specified, its value will be used to override the default373* of the property.374*375* @since 1.7376*/377public static final String ACCESS_EXTERNAL_STYLESHEET = "http://javax.xml.XMLConstants/property/accessExternalStylesheet";378379380/**381* Feature: useCatalog382*383* <p>384* Instructs XML processors to use XML Catalogs to resolve entity references.385* Catalogs may be set through JAXP factories, system properties, or386* jaxp.properties by using the {@code javax.xml.catalog.files} property387* defined in {@link javax.xml.catalog.CatalogFeatures}.388* The following code enables Catalog on SAX parser:389* <pre>{@code390* SAXParserFactory spf = SAXParserFactory.newInstance();391* spf.setFeature(XMLConstants.USE_CATALOG, true);392* SAXParser parser = spf.newSAXParser();393* parser.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), "catalog.xml");394* }</pre>395*396* <p>397* <b>Value:</b> a boolean. If the value is true, and a catalog is set,398* the XML parser will resolve external references using399* {@link javax.xml.catalog.CatalogResolver}. If the value is false,400* XML Catalog is ignored even if one is set. The default value is true.401*402* <p>403* <b>System Property:</b> The value of this property can be set or overridden by404* system property {@code javax.xml.useCatalog}405*406* <p>407* <b>jaxp.properties:</b> This configuration file is in standard408* {@link java.util.Properties} format and typically located in the {@code conf}409* directory of the Java installation. If the file exists and the system410* property is specified, its value will be used to override the default411* value of the property.412*413* @since 9414*/415public static final String USE_CATALOG = "http://javax.xml.XMLConstants/feature/useCatalog";416417}418419420