src/share/jaxws_classes/javax/xml/bind/annotation/XmlSchema.java

Thu, 31 Aug 2017 15:18:52 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:18:52 +0800
changeset 637
9c07ef4934dd
parent 397
b99d7e355d4b
parent 0
373ffda63c9a
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation. Oracle designates this
aoqi@0 8 * particular file as subject to the "Classpath" exception as provided
aoqi@0 9 * by Oracle in the LICENSE file that accompanied this code.
aoqi@0 10 *
aoqi@0 11 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 14 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 15 * accompanied this code).
aoqi@0 16 *
aoqi@0 17 * You should have received a copy of the GNU General Public License version
aoqi@0 18 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 20 *
aoqi@0 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 22 * or visit www.oracle.com if you need additional information or have any
aoqi@0 23 * questions.
aoqi@0 24 */
aoqi@0 25
aoqi@0 26 package javax.xml.bind.annotation;
aoqi@0 27
aoqi@0 28 import java.lang.annotation.Retention;
aoqi@0 29 import java.lang.annotation.Target;
aoqi@0 30
aoqi@0 31 import static java.lang.annotation.ElementType.*;
aoqi@0 32 import static java.lang.annotation.RetentionPolicy.*;
aoqi@0 33
aoqi@0 34 /**
aoqi@0 35 * <p> Maps a package name to a XML namespace. </p>
aoqi@0 36 *
aoqi@0 37 * <h3>Usage</h3>
aoqi@0 38 * <p>
aoqi@0 39 * The XmlSchema annotation can be used with the following program
aoqi@0 40 * elements:
aoqi@0 41 * <ul>
aoqi@0 42 * <li>package</li>
aoqi@0 43 * </ul>
aoqi@0 44 *
aoqi@0 45 * <p>
aoqi@0 46 * This is a package level annotation and follows the recommendations
aoqi@0 47 * and restrictions contained in JSR 175, section III, "Annotations".
aoqi@0 48 * Thus the usage is subject to the following constraints and
aoqi@0 49 * recommendations.
aoqi@0 50 * <ul>
aoqi@0 51 * <li> There can only be one package declaration as noted in JSR
aoqi@0 52 * 175, section III, "Annotations". </li>
aoqi@0 53 * <li> JSR 175 recommends package-info.java for package level
aoqi@0 54 * annotations. JAXB Providers that follow this recommendation
aoqi@0 55 * will allow the package level annotations to be defined in
aoqi@0 56 * package-info.java.
aoqi@0 57 * </ul>
aoqi@0 58 * <p>
aoqi@0 59 *
aoqi@0 60 * <p><b>Example 1:</b> Customize name of XML namespace to which
aoqi@0 61 * package is mapped.</p>
aoqi@0 62 *
aoqi@0 63 * <pre>
aoqi@0 64 * &#64;javax.xml.bind.annotation.XmlSchema (
aoqi@0 65 * namespace = "http://www.example.com/MYPO1"
aoqi@0 66 * )
aoqi@0 67 *
aoqi@0 68 * &lt;!-- XML Schema fragment -->
aoqi@0 69 * &lt;schema
aoqi@0 70 * xmlns=...
aoqi@0 71 * xmlns:po=....
aoqi@0 72 * targetNamespace="http://www.example.com/MYPO1"
aoqi@0 73 * >
aoqi@0 74 * &lt;!-- prefixes generated by default are implementation
aoqi@0 75 * depedenent -->
aoqi@0 76 * </pre>
aoqi@0 77 *
aoqi@0 78 * <p><b>Example 2:</b> Customize namespace prefix, namespace URI
aoqi@0 79 * mapping</p>
aoqi@0 80 *
aoqi@0 81 * <pre>
aoqi@0 82 * // Package level annotation
aoqi@0 83 * &#64;javax.xml.bind.annotation.XmlSchema (
aoqi@0 84 * xmlns = {
aoqi@0 85 * &#64;javax.xml.bind.annotation.XmlNs(prefix = "po",
aoqi@0 86 * namespaceURI="http://www.example.com/myPO1"),
aoqi@0 87 *
aoqi@0 88 * &#64;javax.xml.bind.annotation.XmlNs(prefix="xs",
aoqi@0 89 * namespaceURI="http://www.w3.org/2001/XMLSchema")
aoqi@0 90 * )
aoqi@0 91 * )
aoqi@0 92 *
aoqi@0 93 * &lt;!-- XML Schema fragment -->
aoqi@0 94 * &lt;schema
aoqi@0 95 * xmlns:xs="http://www.w3.org/2001/XMLSchema"
aoqi@0 96 * xmlns:po="http://www.example.com/PO1"
aoqi@0 97 * targetNamespace="http://www.example.com/PO1">
aoqi@0 98 *
aoqi@0 99 * </pre>
aoqi@0 100 *
aoqi@0 101 * <p><b>Example 3:</b> Customize elementFormDefault</p>
aoqi@0 102 * <pre>
aoqi@0 103 * &#64;javax.xml.bind.annotation.XmlSchema (
aoqi@0 104 * elementFormDefault=XmlNsForm.UNQUALIFIED
aoqi@0 105 * ...
aoqi@0 106 * )
aoqi@0 107 *
aoqi@0 108 * &lt;!-- XML Schema fragment -->
aoqi@0 109 * &lt;schema
aoqi@0 110 * xmlns="http://www.w3.org/2001/XMLSchema"
aoqi@0 111 * xmlns:po="http://www.example.com/PO1"
aoqi@0 112 * elementFormDefault="unqualified">
aoqi@0 113 *
aoqi@0 114 * </pre>
aoqi@0 115
aoqi@0 116 * @author Sekhar Vajjhala, Sun Microsystems, Inc.
aoqi@0 117 * @since JAXB2.0
aoqi@0 118 */
aoqi@0 119
aoqi@0 120 @Retention(RUNTIME) @Target(PACKAGE)
aoqi@0 121 public @interface XmlSchema {
aoqi@0 122
aoqi@0 123 /**
aoqi@0 124 * Customize the namespace URI, prefix associations. By default,
aoqi@0 125 * the namespace prefixes for a XML namespace are generated by a
aoqi@0 126 * JAXB Provider in an implementation dependent way.
aoqi@0 127 */
aoqi@0 128 XmlNs[] xmlns() default {};
aoqi@0 129
aoqi@0 130 /**
aoqi@0 131 * Name of the XML namespace.
aoqi@0 132 */
aoqi@0 133 String namespace() default "";
aoqi@0 134
aoqi@0 135 /**
aoqi@0 136 * Namespace qualification for elements. By default, element
aoqi@0 137 * default attribute will be absent from the XML Schema fragment.
aoqi@0 138 */
aoqi@0 139 XmlNsForm elementFormDefault() default XmlNsForm.UNSET;
aoqi@0 140
aoqi@0 141 /**
aoqi@0 142 * Namespace qualification for attributes. By default,
aoqi@0 143 * attributesFormDefault will be absent from the XML Schema fragment.
aoqi@0 144 */
aoqi@0 145 XmlNsForm attributeFormDefault() default XmlNsForm.UNSET;
aoqi@0 146
aoqi@0 147 /**
aoqi@0 148 * Indicates that this namespace (specified by {@link #namespace()})
aoqi@0 149 * has a schema already available exeternally, available at this location.
aoqi@0 150 *
aoqi@0 151 * <p>
aoqi@0 152 * This instructs the JAXB schema generators to simply refer to
aoqi@0 153 * the pointed schema, as opposed to generating components into the schema.
aoqi@0 154 * This schema is assumed to match what would be otherwise produced
aoqi@0 155 * by the schema generator (same element names, same type names...)
aoqi@0 156 *
aoqi@0 157 * <p>
aoqi@0 158 * This feature is intended to be used when a set of the Java classes
aoqi@0 159 * is originally generated from an existing schema, hand-written to
aoqi@0 160 * match externally defined schema, or the generated schema is modified
aoqi@0 161 * manually.
aoqi@0 162 *
aoqi@0 163 * <p>
aoqi@0 164 * Value could be any absolute URI, like <tt>http://example.org/some.xsd</tt>.
aoqi@0 165 * It is also possible to specify the empty string, to indicate
aoqi@0 166 * that the schema is externally available but the location is
aoqi@0 167 * unspecified (and thus it's the responsibility of the reader of the generate
aoqi@0 168 * schema to locate it.) Finally, the default value of this property
aoqi@0 169 * <tt>"##generate"</tt> indicates that the schema generator is going
aoqi@0 170 * to generate components for this namespace (as it did in JAXB 2.0.)
aoqi@0 171 *
aoqi@0 172 * <p>
aoqi@0 173 * Multiple {@link XmlSchema} annotations on multiple packages are allowed
aoqi@0 174 * to govern the same {@link #namespace()}. In such case, all of them
aoqi@0 175 * must have the same {@link #location()} values.
aoqi@0 176 *
aoqi@0 177 *
aoqi@0 178 * <h3>Note to implementor</h3>
aoqi@0 179 * <p>
aoqi@0 180 * More precisely, the value must be either <tt>""</tt>, <tt>"##generate"</tt>, or
aoqi@0 181 * <a href="http://www.w3.org/TR/xmlschema-2/#anyURI">
aoqi@0 182 * a valid lexical representation of <tt>xs:anyURI</tt></a> that begins
aoqi@0 183 * with <tt>&lt;scheme>:</tt>.
aoqi@0 184 *
aoqi@0 185 * <p>
aoqi@0 186 * A schema generator is expected to generate a corresponding
aoqi@0 187 * <tt>&lt;xs:import namespace="..." schemaLocation="..."/></tt> (or
aoqi@0 188 * no <tt>schemaLocation</tt> attribute at all if the empty string is specified.)
aoqi@0 189 * However, the schema generator is allowed to use a different value in
aoqi@0 190 * the <tt>schemaLocation</tt> attribute (including not generating
aoqi@0 191 * such attribute), for example so that the user can specify a local
aoqi@0 192 * copy of the resource through the command line interface.
aoqi@0 193 *
aoqi@0 194 * @since JAXB2.1
aoqi@0 195 */
aoqi@0 196 String location() default NO_LOCATION;
aoqi@0 197
aoqi@0 198 /**
aoqi@0 199 * The default value of the {@link #location()} attribute,
aoqi@0 200 * which indicates that the schema generator will generate
aoqi@0 201 * components in this namespace.
aoqi@0 202 */
aoqi@0 203 // the actual value is chosen because ## is not a valid
aoqi@0 204 // sequence in xs:anyURI.
aoqi@0 205 static final String NO_LOCATION = "##generate";
aoqi@0 206 }

mercurial