001 /*
002 * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package javax.xml.bind.annotation;
027
028 import java.lang.annotation.Retention;
029 import java.lang.annotation.Target;
030
031 import static java.lang.annotation.ElementType.*;
032 import static java.lang.annotation.RetentionPolicy.*;
033
034 /**
035 * <p> Maps a package name to a XML namespace. </p>
036 *
037 * <p><b>Usage</b> </p>
038 * <p>
039 * The XmlSchema annotation can be used with the following program
040 * elements:
041 * <ul>
042 * <li>package</li>
043 * </ul>
044 *
045 * This is a package level annotation and follows the recommendations
046 * and restrictions contained in JSR 175, section III, "Annotations".
047 * Thus the usage is subject to the following constraints and
048 * recommendations.
049 * <ul>
050 * <li> There can only be one package declaration as noted in JSR
051 * 175, section III, "Annotations". </li>
052 * <li> JSR 175 recommends package-info.java for package level
053 * annotations. JAXB Providers that follow this recommendation
054 * will allow the package level annotations to be defined in
055 * package-info.java.
056 * </ul>
057 * <p>
058 *
059 * <p><b>Example 1:</b> Customize name of XML namespace to which
060 * package is mapped.</p>
061 *
062 * <pre>
063 * @javax.xml.bind.annotation.XmlSchema (
064 * namespace = "http://www.example.com/MYPO1"
065 * )
066 *
067 * <!-- XML Schema fragment -->
068 * <schema
069 * xmlns=...
070 * xmlns:po=....
071 * targetNamespace="http://www.example.com/MYPO1"
072 * >
073 * <!-- prefixes generated by default are implementation
074 * depedenent -->
075 * </pre>
076 *
077 * <p><b>Example 2:</b> Customize namespace prefix, namespace URI
078 * mapping</p>
079 *
080 * <pre>
081 * // Package level annotation
082 * @javax.xml.bind.annotation.XmlSchema (
083 * xmlns = {
084 * @javax.xml.bind.annotation.XmlNs(prefix = "po",
085 * namespaceURI="http://www.example.com/myPO1"),
086 *
087 * @javax.xml.bind.annotation.XmlNs(prefix="xs",
088 * namespaceURI="http://www.w3.org/2001/XMLSchema")
089 * )
090 * )
091 *
092 * <!-- XML Schema fragment -->
093 * <schema
094 * xmlns:xs="http://www.w3.org/2001/XMLSchema"
095 * xmlns:po="http://www.example.com/PO1"
096 * targetNamespace="http://www.example.com/PO1">
097 *
098 * </pre>
099 *
100 * <p><b>Example 3:</b> Customize elementFormDefault</p>
101 * <pre>
102 * @javax.xml.bind.annotation.XmlSchema (
103 * elementFormDefault=XmlNsForm.UNQUALIFIED
104 * ...
105 * )
106 *
107 * <!-- XML Schema fragment -->
108 * <schema
109 * xmlns="http://www.w3.org/2001/XMLSchema"
110 * xmlns:po="http://www.example.com/PO1"
111 * elementFormDefault="unqualified">
112 *
113 * </pre>
114
115 * @author Sekhar Vajjhala, Sun Microsystems, Inc.
116 * @since JAXB2.0
117 * @version $Revision: 1.8 $
118 */
119
120 @Retention(RUNTIME)
121 @Target({PACKAGE})
122 public @interface XmlSchema {
123
124 /**
125 * Customize the namespace URI, prefix associations. By default,
126 * the namespace prefixes for a XML namespace are generated by a
127 * JAXB Provider in an implementation dependent way.
128 */
129 XmlNs[] xmlns() default {};
130
131 /**
132 * Name of the XML namespace.
133 */
134 String namespace() default "";
135
136 /**
137 * Namespace qualification for elements. By default, element
138 * default attribute will be absent from the XML Schema fragment.
139 */
140 XmlNsForm elementFormDefault() default XmlNsForm.UNSET;
141
142 /**
143 * Namespace qualification for attributes. By default,
144 * attributesFormDefault will be absent from the XML Schema fragment.
145 */
146 XmlNsForm attributeFormDefault() default XmlNsForm.UNSET;
147 }
|