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

Tue, 09 Apr 2013 14:51:13 +0100

author
alanb
date
Tue, 09 Apr 2013 14:51:13 +0100
changeset 368
0989ad8c0860
parent 286
f50545b5e2f1
child 397
b99d7e355d4b
permissions
-rw-r--r--

8010393: Update JAX-WS RI to 2.2.9-b12941
Reviewed-by: alanb, erikj
Contributed-by: miroslav.kos@oracle.com, martin.grebac@oracle.com

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

mercurial