您的位置:首页 > 其它

JAXB - Annotations, Annotations for the Schema: XmlSchema

2016-05-20 13:05 447 查看
This annotation can only be used with a package. It defines parameters that are derived from the
xsd:schema
element. It must be written on a file
package-info.java
situated in the package. Below is an example, specifying the
namespace
and
elementFormDefault
elements.

@javax.xml.bind.annotation.XmlSchema(
namespace = "http://www.laune.at/hospital",
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package hospital;


This annotation is equivalent to an
xs:schema
element

<xs:schema elementFormDefault="qualified"
targetNamespace="http://www.laune.at/hospital"
xmlns:tns="http://www.laune.at/hospital"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="1.0" >


For defining namespace prefixes you use the
xmlns
element of the
XmlSchema
annotation. It contains an array of
XmlNs
annotations, each of which contains a
prefix
and a
namespaceURI
element. The previous example is extended with a namespace definition for the prefix
med
:

@javax.xml.bind.annotation.XmlSchema(
namespace = "http://www.laune.at/hospital",
xmlns = { @javax.xml.bind.annotation.XmlNs( prefix = "med",
namespaceURI = "http://www.laune.at/med" ) },
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package hospital;


This corresponds to using
xmlns:med="http://www.laune.at/med"
as an attribute in the
xs:schema
element.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: