|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
javax.xml.bind.annotation Annotation Type XmlSchema
Implements:
Annotation
@Retention(value=RUNTIME)@Target(value=PACKAGE)
将包名称映射到 XML 名称空间。
用法
XmlSchema 注释可以与以下程序元素一起使用:
- 包
- 正如 JSR 175 的第 III 节“注释”中所指出的那样,只能有一个包声明。
- JSR 175 建议对包级别注释使用 package-info.java。遵循此建议的 JAXB 提供者将允许在 package-info.java 中定义包级别注释。
示例 1:自定义包将要映射到的 XML 名称空间名。
@javax.xml.bind.annotation.XmlSchema ( namespace = "http://www.example.com/MYPO1" ) <!-- XML Schema fragment --> <schema xmlns=... xmlns:po=.... targetNamespace="http://www.example.com/MYPO1" > <!-- prefixes generated by default are implementation depedenent -->
示例 2:自定义名称空间前缀、名称空间 URI 映射
// Package level annotation @javax.xml.bind.annotation.XmlSchema ( xmlns = { @javax.xml.bind.annotation.XmlNs(prefix = "po", namespaceURI="http://www.example.com/myPO1"), @javax.xml.bind.annotation.XmlNs(prefix="xs", namespaceURI="http://www.w3.org/2001/XMLSchema") ) ) <!-- XML Schema fragment --> <schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:po="http://www.example.com/PO1" targetNamespace="http://www.example.com/PO1">
示例 3:自定义 elementFormDefault
@javax.xml.bind.annotation.XmlSchema ( elementFormDefault=XmlNsForm.UNQUALIFIED ... ) <!-- XML Schema fragment --> <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:po="http://www.example.com/PO1" elementFormDefault="unqualified">
since | JAXB2.0 | |
version |
|
Maps a package name to a XML namespace.
Usage
The XmlSchema annotation can be used with the following program elements:
- package
- There can only be one package declaration as noted in JSR 175, section III, "Annotations".
- JSR 175 recommends package-info.java for package level annotations. JAXB Providers that follow this recommendation will allow the package level annotations to be defined in package-info.java.
Example 1: Customize name of XML namespace to which package is mapped.
@javax.xml.bind.annotation.XmlSchema ( namespace = "http://www.example.com/MYPO1" ) <!-- XML Schema fragment --> <schema xmlns=... xmlns:po=.... targetNamespace="http://www.example.com/MYPO1" > <!-- prefixes generated by default are implementation depedenent -->
Example 2: Customize namespace prefix, namespace URI mapping
// Package level annotation @javax.xml.bind.annotation.XmlSchema ( xmlns = { @javax.xml.bind.annotation.XmlNs(prefix = "po", namespaceURI="http://www.example.com/myPO1"), @javax.xml.bind.annotation.XmlNs(prefix="xs", namespaceURI="http://www.w3.org/2001/XMLSchema") ) ) <!-- XML Schema fragment --> <schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:po="http://www.example.com/PO1" targetNamespace="http://www.example.com/PO1">
Example 3: Customize elementFormDefault
@javax.xml.bind.annotation.XmlSchema ( elementFormDefault=XmlNsForm.UNQUALIFIED ... ) <!-- XML Schema fragment --> <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:po="http://www.example.com/PO1" elementFormDefault="unqualified">
- Since:
- JAXB2.0
- Version:
- $Revision: 1.9 $
- Author:
- Sekhar Vajjhala, Sun Microsystems, Inc.
Optional Element Summary | |
---|---|
XmlNsForm |
attributeFormDefault
Namespace qualification for attributes. |
XmlNsForm |
elementFormDefault
Namespace qualification for elements. |
String |
namespace
Name of the XML namespace. |
XmlNs[] |
xmlns
Customize the namespace URI, prefix associations. |
abstract public XmlNs[]
xmlns()
自定义名称空间 URI 和前缀的关联性。默认情况下,XML 名称空间的名称空间前缀是由 JAXB 提供者以与实现相关的方式生成的。
英文文档:
xmlns
public abstract XmlNs[] xmlns
- Customize the namespace URI, prefix associations. By default,
the namespace prefixes for a XML namespace are generated by a
JAXB Provider in an implementation dependent way.
- Default:
- {}
abstract public String
namespace()
XML 名称空间名。
英文文档:
namespace
public abstract String namespace
- Name of the XML namespace.
- Default:
- ""
abstract public XmlNsForm
elementFormDefault()
元素的名称空间限制。默认情况下,元素默认属性不在 XML 模式片段中。
英文文档:
elementFormDefault
public abstract XmlNsForm elementFormDefault
- Namespace qualification for elements. By default, element
default attribute will be absent from the XML Schema fragment.
- Default:
- UNSET
abstract public XmlNsForm
attributeFormDefault()
属性的名称空间限制。默认情况下,attributesFormDefault 不在 XML 模式片段中。
英文文档:
attributeFormDefault
public abstract XmlNsForm attributeFormDefault
- Namespace qualification for attributes. By default,
attributesFormDefault will be absent from the XML Schema fragment.
- Default:
- UNSET
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT |
Submit a bug or feature
Copyright 2007 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.
PS : 未经我党受权你也可自由散发此文档。 如有任何错误请自行修正;若因此而造成任何损失请直接找人民主席,请勿与本人联系。谢谢!