|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 必需 | 可選 | 詳細資訊: 元素 | |||||||||
@Retention(value=RUNTIME) @Target(value=PACKAGE) public @interface XmlSchema
將套件名稱映射到 XML 名稱空間。
用法
XmlSchema 註釋可以與以下程序元素一起使用:
範例 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">
| 可選元素摘要 | |
|---|---|
XmlNsForm |
attributeFormDefault
屬性的名稱空間限制。 |
XmlNsForm |
elementFormDefault
元素的名稱空間限制。 |
String |
namespace
XML 名稱空間名。 |
XmlNs[] |
xmlns
自定義名稱空間 URI 和前綴的關聯性。 |
public abstract XmlNs[] xmlns
public abstract String namespace
public abstract XmlNsForm elementFormDefault
public abstract XmlNsForm attributeFormDefault
|
JavaTM 2 Platform Standard Ed. 6 |
|||||||||
| 上一個類別 下一個類別 | 框架 無框架 | |||||||||
| 摘要: 必需 | 可選 | 詳細資訊: 元素 | |||||||||
版權所有 2008 Sun Microsystems, Inc. 保留所有權利。請遵守GNU General Public License, version 2 only。