ohair@286: /* ohair@286: * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. ohair@286: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ohair@286: * ohair@286: * This code is free software; you can redistribute it and/or modify it ohair@286: * under the terms of the GNU General Public License version 2 only, as ohair@286: * published by the Free Software Foundation. Oracle designates this ohair@286: * particular file as subject to the "Classpath" exception as provided ohair@286: * by Oracle in the LICENSE file that accompanied this code. ohair@286: * ohair@286: * This code is distributed in the hope that it will be useful, but WITHOUT ohair@286: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ohair@286: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ohair@286: * version 2 for more details (a copy is included in the LICENSE file that ohair@286: * accompanied this code). ohair@286: * ohair@286: * You should have received a copy of the GNU General Public License version ohair@286: * 2 along with this work; if not, write to the Free Software Foundation, ohair@286: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ohair@286: * ohair@286: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@286: * or visit www.oracle.com if you need additional information or have any ohair@286: * questions. ohair@286: */ ohair@286: ohair@286: package javax.xml.bind.annotation; ohair@286: ohair@286: import java.lang.annotation.Retention; ohair@286: import java.lang.annotation.Target; ohair@286: ohair@286: import static java.lang.annotation.ElementType.*; ohair@286: import static java.lang.annotation.RetentionPolicy.*; ohair@286: ohair@286: /** ohair@286: *
Maps a package name to a XML namespace.
ohair@286: * ohair@286: *ohair@286: * The XmlSchema annotation can be used with the following program ohair@286: * elements: ohair@286: *
ohair@286: * This is a package level annotation and follows the recommendations ohair@286: * and restrictions contained in JSR 175, section III, "Annotations". ohair@286: * Thus the usage is subject to the following constraints and ohair@286: * recommendations. ohair@286: *
ohair@286: * ohair@286: *
Example 1: Customize name of XML namespace to which ohair@286: * package is mapped.
ohair@286: * ohair@286: *ohair@286: * @javax.xml.bind.annotation.XmlSchema ( ohair@286: * namespace = "http://www.example.com/MYPO1" ohair@286: * ) ohair@286: * ohair@286: * <!-- XML Schema fragment --> ohair@286: * <schema ohair@286: * xmlns=... ohair@286: * xmlns:po=.... ohair@286: * targetNamespace="http://www.example.com/MYPO1" ohair@286: * > ohair@286: * <!-- prefixes generated by default are implementation ohair@286: * depedenent --> ohair@286: *ohair@286: * ohair@286: *
Example 2: Customize namespace prefix, namespace URI ohair@286: * mapping
ohair@286: * ohair@286: *ohair@286: * // Package level annotation ohair@286: * @javax.xml.bind.annotation.XmlSchema ( ohair@286: * xmlns = { ohair@286: * @javax.xml.bind.annotation.XmlNs(prefix = "po", ohair@286: * namespaceURI="http://www.example.com/myPO1"), ohair@286: * ohair@286: * @javax.xml.bind.annotation.XmlNs(prefix="xs", ohair@286: * namespaceURI="http://www.w3.org/2001/XMLSchema") ohair@286: * ) ohair@286: * ) ohair@286: * ohair@286: * <!-- XML Schema fragment --> ohair@286: * <schema ohair@286: * xmlns:xs="http://www.w3.org/2001/XMLSchema" ohair@286: * xmlns:po="http://www.example.com/PO1" ohair@286: * targetNamespace="http://www.example.com/PO1"> ohair@286: * ohair@286: *ohair@286: * ohair@286: *
Example 3: Customize elementFormDefault
ohair@286: *ohair@286: * @javax.xml.bind.annotation.XmlSchema ( ohair@286: * elementFormDefault=XmlNsForm.UNQUALIFIED ohair@286: * ... ohair@286: * ) ohair@286: * ohair@286: * <!-- XML Schema fragment --> ohair@286: * <schema ohair@286: * xmlns="http://www.w3.org/2001/XMLSchema" ohair@286: * xmlns:po="http://www.example.com/PO1" ohair@286: * elementFormDefault="unqualified"> ohair@286: * ohair@286: *ohair@286: ohair@286: * @author Sekhar Vajjhala, Sun Microsystems, Inc. ohair@286: * @since JAXB2.0 ohair@286: */ ohair@286: ohair@286: @Retention(RUNTIME) @Target(PACKAGE) ohair@286: public @interface XmlSchema { ohair@286: ohair@286: /** ohair@286: * Customize the namespace URI, prefix associations. By default, ohair@286: * the namespace prefixes for a XML namespace are generated by a ohair@286: * JAXB Provider in an implementation dependent way. ohair@286: */ ohair@286: XmlNs[] xmlns() default {}; ohair@286: ohair@286: /** ohair@286: * Name of the XML namespace. ohair@286: */ ohair@286: String namespace() default ""; ohair@286: ohair@286: /** ohair@286: * Namespace qualification for elements. By default, element ohair@286: * default attribute will be absent from the XML Schema fragment. ohair@286: */ ohair@286: XmlNsForm elementFormDefault() default XmlNsForm.UNSET; ohair@286: ohair@286: /** ohair@286: * Namespace qualification for attributes. By default, ohair@286: * attributesFormDefault will be absent from the XML Schema fragment. ohair@286: */ ohair@286: XmlNsForm attributeFormDefault() default XmlNsForm.UNSET; ohair@286: ohair@286: /** ohair@286: * Indicates that this namespace (specified by {@link #namespace()}) ohair@286: * has a schema already available exeternally, available at this location. ohair@286: * ohair@286: *
ohair@286: * This instructs the JAXB schema generators to simply refer to ohair@286: * the pointed schema, as opposed to generating components into the schema. ohair@286: * This schema is assumed to match what would be otherwise produced ohair@286: * by the schema generator (same element names, same type names...) ohair@286: * ohair@286: *
ohair@286: * This feature is intended to be used when a set of the Java classes ohair@286: * is originally generated from an existing schema, hand-written to ohair@286: * match externally defined schema, or the generated schema is modified ohair@286: * manually. ohair@286: * ohair@286: *
ohair@286: * Value could be any absolute URI, like http://example.org/some.xsd. ohair@286: * It is also possible to specify the empty string, to indicate ohair@286: * that the schema is externally available but the location is ohair@286: * unspecified (and thus it's the responsibility of the reader of the generate ohair@286: * schema to locate it.) Finally, the default value of this property ohair@286: * "##generate" indicates that the schema generator is going ohair@286: * to generate components for this namespace (as it did in JAXB 2.0.) ohair@286: * ohair@286: *
ohair@286: * Multiple {@link XmlSchema} annotations on multiple packages are allowed ohair@286: * to govern the same {@link #namespace()}. In such case, all of them ohair@286: * must have the same {@link #location()} values. ohair@286: * ohair@286: * ohair@286: *
ohair@286: * More precisely, the value must be either "", "##generate", or ohair@286: * ohair@286: * a valid lexical representation of xs:anyURI that begins ohair@286: * with <scheme>:. ohair@286: * ohair@286: *
ohair@286: * A schema generator is expected to generate a corresponding ohair@286: * <xs:import namespace="..." schemaLocation="..."/> (or ohair@286: * no schemaLocation attribute at all if the empty string is specified.) ohair@286: * However, the schema generator is allowed to use a different value in ohair@286: * the schemaLocation attribute (including not generating ohair@286: * such attribute), for example so that the user can specify a local ohair@286: * copy of the resource through the command line interface. ohair@286: * ohair@286: * @since JAXB2.1 ohair@286: */ ohair@286: String location() default NO_LOCATION; ohair@286: ohair@286: /** ohair@286: * The default value of the {@link #location()} attribute, ohair@286: * which indicates that the schema generator will generate ohair@286: * components in this namespace. ohair@286: */ ohair@286: // the actual value is chosen because ## is not a valid ohair@286: // sequence in xs:anyURI. ohair@286: static final String NO_LOCATION = "##generate"; ohair@286: }