@Retention(value=RUNTIME) @Target(value=PACKAGE) public @interface XmlSchema
将包名称映射到XML命名空间。
XmlSchema的注释可以用下面的程序元素:
这是一个包级标注为包含在JSR 175,第三节的建议和限制,“注释”。因此,使用是受以下的约束和建议。
例1:自定义名称的XML命名空间映射,包。
@javax.xml.bind.annotation.xmlschema(命名空间=“http://www.example.com/mypo1”)<!“XML模式片段”> <模式xmlns =…xmlns:宝="的…目标=“http://www.example.com/mypo1”"> <!-默认生成的前缀是实现depedenent --> 模式xmlns>
例2:自定义命名空间前缀的命名空间URI映射
/包级注释@javax.xml.bind.annotation.xmlschema(xmlns = {@ javax. XML绑定。注释。xmlns(前缀=“宝”,namespaceuri =“http:/ / www.example。COM / mypo1”),@ javax. XML绑定。注释。xmlns(前缀=“X”,namespaceuri =“http:/ /两。org / 2001 /模式”)))<!“XML模式片段”> <模式xmlns:xs =“http: www.w3.org 001 mlschema”xmlns:宝="“http://www.example.com/po1”目标=“http:/" www.example。com po1”>模式xmlns:xs>
例3:定制elementFormDefault
@javax.xml.bind.annotation.xmlschema(xmlnsform.unqualified elementFormDefault =…)<!“XML模式片段”> <模式xmlns =“http: www.w3.org 001 mlschema”xmlns:宝="“http://www.example.com/po1”elementFormDefault" =“不合格”>模式xmlns>
Modifier and Type | Fields and Description |
---|---|
static String |
NO_LOCATION
该
location() 属性的默认值,这表明模式发生器将在这个命名空间生成组件。
|
Modifier and Type | Optional Element and Description |
---|---|
XmlNsForm |
attributeFormDefault
属性的命名空间限定。
|
XmlNsForm |
elementFormDefault
元素的命名空间限定。
|
String |
location
表明该命名空间(指定的
namespace() )具有架构已经exeternally,在此位置可。
|
String |
namespace
命名空间的名称。
|
XmlNs[] |
xmlns
自定义命名空间URI前缀协会。
|
public static final String NO_LOCATION
location()
属性的默认值,这表明模式发生器将在这个命名空间生成组件。
public abstract XmlNs[] xmlns
public abstract String namespace
public abstract XmlNsForm elementFormDefault
public abstract XmlNsForm attributeFormDefault
public abstract String location
namespace()
)具有架构已经exeternally,在此位置可。
这指示JAXB模式发生器只是指尖的模式,而不是生成组件架构。这种模式被假定为匹配模式发生器(相同的元素名称,相同的类型名称),否则会产生什么样的……
此功能是用来当一组java类是从现有的架构最初生成,手写与外部定义的模式,或是手动修改生成的架构。
值可以是任何的绝对URI,像http://example.org/some.xsd。它也可以指定空字符串,表示该模式是外部可用但位置是不确定的(因此它的生成模式来定位它。读者的责任)最后,这个属性的默认值"##generate"表明模式发生器来产生这个命名空间组件(因为它没有在JAXB 2。)
多个包的多个XmlSchema
注释允许政府相同的namespace()
。在这种情况下,他们都必须有相同的location()
值。
更确切地说,该值必须是"","##generate",或 a valid lexical representation of xs:anyURI始于<scheme>:。
模式发生器将产生相应的<xs:import namespace="..." schemaLocation="..."/>(或没有schemaLocation属性在所有如果空字符串指定。)然而,模式发生器允许在schemaLocation属性使用不同的值(包括不产生这样的属性),例如,用户可以指定资源的本地副本通过命令行界面。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.