xsnot并暮

(圈出句子所有的错别字并改正下来):既使被挤在厚厚的暮布里,闷得满头是汗,也兴味昂然.
红人赤衣用
即使幕布兴味盎然
为您推荐:
其他类似问题
(既)【即】使被挤在厚厚的(暮)【幕】布里,闷得满头是汗,也兴味(昂)【盎】然。
既使 改为 即使暮布 改为 幕布兴味昂然 改为 兴味盎然
扫描下载二维码语文老师说有 暮蔼和暮霭都是对的,可是我在网上查过了并没有暮蔼一词,谁能告诉我到底哪_百度知道
语文老师说有 暮蔼和暮霭都是对的,可是我在网上查过了并没有暮蔼一词,谁能告诉我到底哪
个是对的啊,谢谢大神帮忙
提问者采纳
记住“吾爱吾师。弄清就可以了,你在哪儿也找不到了,同时在书面语中;暮霭&没有“暮蔼”这个词了,不要再和老师辩论了。有可能是老师弄错了。现在已经统一为&quot,也形容树木茂盛,态度好。二者不同,但更爱真理”“蔼”是和气。而“霭”则是云气烟雾的意思
其他类似问题
为您推荐:
其他2条回答
古时,语言发展还不规范,所以可以说“蔼”和“霭”是可以通用的。
意思都是一个意思。 应该都是对的,
语文老师的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁解释我并没有不能启齿的往事,山间也很久没有过路的僧子.忌爱恨嗔痴,以朝生暮_百度知道
解释我并没有不能启齿的往事,山间也很久没有过路的僧子.忌爱恨嗔痴,以朝生暮
恨,最要诫勉的就是“爱,山中也已经很久没有路过的和尚了我并没有不能说出来的过去、嗔
其他类似问题
为您推荐:
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁This section provides guidelines for designing a XML schema exported by a Java web service designed starting from Java. JAXB 2.0 provides a rich set of annotations and types for mapping Java classes to different XML Schema constructs. The guidelines provide guidance on using JAXB 2.0 annotations and types so that developer friendly bindings may be generated by XML serialization mechanisms (svcutil) on WCF client.
Not all JAXB 2.0 annotatio not all are relevant from an interoperability standpoint. For example, the annotation @XmlAccessorType provides control over default serialization of fields and properties in a Java class but otherwise has no effect on the on-the-wire XML representation or the XML schema generated from a Java class. Select JAXB 2.0 annotations are therefore not included here in the guidance.
The guidance includes several examples, which use the following conventions:
prefix xs: is used to represent XML Schema namespace
JAXB 2.0 annotations are defined in javax.xml.bind.annotation package but, for brevity, the package name has been omitted
Guideline: Java primitive and wrapper classes map to slightly different XML schema representations. Therefore, .NET bindings will vary accordingly.
Example: A Java primitive type and its corresponding wrapper class
//-- Java code fragment
public class StockItem{
&&&&public Double wholeSaleP
&&&&public double retailP
//--Schema fragment
&xs:complexType name=&stockItem&&
&xs:sequence&
&xs:element name=&wholeSalePrice& type=&xs:double&
&&&&&&&&&&minOccurs=&0&/&
&xs:element name=&retailPrice& type=&xs:double&/&
&/xs:sequence&
&/xs:complexType&
//-- .NET C# auto generated code from schema
public partial class stockItem
private double wholeSaleP
private bool wholeSalePriceFieldS
private double retailP
public double wholeSalePrice
get{ return this.wholeSaleP}
set{this.wholeSalePrice=value}
public bool wholeSalePriceSpecified
get{ return
this.wholeSalePriceFieldS}
set{this.wholeSalePriceFieldSpecified=value}
public double retailPrice
get{ return this.retailP}
set{this.retailPrice=value}
//-- C# code fragment
stockItem s = new stockItem();
s.wholeSalePrice = Double.parse(&198.92&);
s.wholeSalePriceSpecified = true
s.retailPrice = Double.parse(&300.25&);
Guideline: Limit decimal values to the range and precision of .NET's System.decimal.
java.math.BigDecimal maps to xs:decimal. .NET maps xs:decimal to System.decimal. These two data types support different range and precision. java.math.BigDecimal supports arbitrary precision. System.decimal does not. For interoperability use only values within the range and precision of System.decimal. (See System.decimal.Minvalue and System.decimal.Maxvalue.) Any values outside of this range require a customized .NET client.
Example: BigDecimal usage
//--- Java code fragment
public class RetBigDecimal {
private BigDecimal arg0;
public BigDecimal getArg0() { return this.arg0; }
public void setArg0(BigDecimal arg0) { this.arg0 = arg0; }
//--- Schema fragment
&xs:complexType name=&retBigDecimal&&
&xs:sequence&
&xs:element name=&arg0& type=&xs:decimal& minOccurs=&0&/&
&/xs:sequence&
&/xs:complexType&
//--- .NET auto generated code from schema
public partial class retBigDecimal{
private decimal arg0F
private bool arg0FieldS
public decimal arg0 {
get { return this.arg0F}
set { this.arg0Field =}
public bool arg0Specified {
get { return this.arg0FieldS}
set { this.arg0FieldSpecified =}
//--- C# code fragment
System.CultureInfo engCulture = new System.CultureInfo(&en-US&);
retBigDecimal bd = new retBigDecimal();
bd.arg0 = System.decimal.MinV
retBigDecimal negBd = new retBigDecimal();
negBd = System.decimal.Parse(&-0.0&, engCulture);
Guideline: Use the @XmlSchemaType annotation for a strongly typed binding to a .NET client generated with the DataContractSerializer.
java.net.URI maps to xs:string. .NET maps xs:string to System.string. Annotation @XmlSchemaType can be used to define a more strongly typed binding to a .NET client generated with the DataContractSerializer. @XmlSchemaType can be used to map java.net.URI to xs:anyURI. .NET's DataContractSerializer and XmlSerializer bind xs:anyURI differently:
DataContractSerializer binds xs:anyURI to .NET type System.Uri
XmlSerializer binds xs:anyURI to .NET type System.string
Thus, the above technique only works if the WSDL is processed using DataContractSerializer.
Example: @XmlSchemaType and DataContractSerializer
// Java code fragment
public class PurchaseOrder
&&@XmlSchemaType(name=&anyURI&)
&&public java.net.URI
//-- Schema fragment
&xs:complexType name=&purchaseOrder&&
&&&xs:sequence&
&&&&&xs:element name=&uri& type=&xs:anyURI& minOccurs=&0&/&
&&&/xs:sequence&
&/xs:complexType&
//--- .NET auto generated code from schema
//--- Using svcutil.exe /serializer:DataContractSerializer &wsdl file&
public partial class purchaseOrder : object,
System.Runtime.Serialization.IExtensibleDataObject
private System.Uri uriF
//-- ..... other gernerated code ........
public System.Uri uri
get { return this.uriF }
set { this.uriField = }
//--- C# code fragment
purchaseOrder tmpU = new purchaseOrder()
tmpU.uri = new System.Uri(&../Hello&,
System.UriKind.Relative);
Example: @XmlSchemaType and XmlSerializer
// Java code fragment
public class PurchaseOrder
&&@XmlSchemaType(name=&anyURI&)
&&public java.net.URI
//--- .NET auto generated code from schema
//--- Using svcutil.exe /serializer:XmlSerializer &wsdl file&
public partial class purchaseOrder
private string uriF
public string uri
get { return this.uriF }
set { this.uriField = }
//--- C# code fragment
purchaseOrder tmpU = new purchaseOrder()
tmpU.uri = &mailto:mailto:mduerst@ifi.unizh.ch&;
Guideline: Use .NET's System.Xml.XmlConvert to generate a lexical representation of xs:duration when the binding is to a type of System.string.
javax.xml.datatype.Duration maps to xs:duration. .NET maps xs:duration to a different datatype for DataContractSerializer and XmlSerializer.
DataContractSerializer binds xs:duration to .NET System.TimeSpan.
XmlSerializer binds xs:duration to .NET System.string.
When xs:duration is bound to .NET System.string, the string value must be a lexical representation for xs:duration. .NET provides utility System.Xml.XmlConvert for this purpose.
Example: Mapping xs:duration using DataContactSerializer
//-- Java code fragment
public class PurchaseReport {
public javax.xml.datatype.D
//-- Schema fragment
&xs:complexType name=&purchaseReport&&
&xs:sequence&
&xs:element name=&period& type=&xs:duration&
minOccurs=&0&/&
&/xs:sequence&
&/xs:complexType&
//-- .NET auto generated code from schema
//-- Using svcutil.exe /serializer:DataContractSerializer &wsdl file&
public partial class purchaseReport: object,
System.Runtime.Serialization.IExtensibleDataObject
private System.TimeSpan periodF
//-- ..... other gernerated code ........
public System.TimeSpan period
get { return this.periodF }
set { this.periodField = }
//-- C# code fragment
purchaseReport tmpR = new purchaseReport();
tmpR.period = new System.TimeSpan.MaxV
Example: Mapping xs:duration using XmlSerializer
//-- .NET auto generated code from schema
//-- Using svcutil.exe /serializer:XmlSerializer &wsdl file&
public partial class purchaseReport
private string periodF
public string period
get { return this.periodF }
set { this.periodField = }
//-- C# code fragment
purchaseReport tmpR = new purchaseReport();
tmpR.period = System.Xml.XmlConvert.ToString(new
System.TimeSpan(23, 0,0));
java.awt.Image, javax.xml.transform.Source, and javax.activation.DataHandler map to xs:base64Binary. .NET maps xs:base64Binary to byte[].
JAXB 2.0 provides the annotation @XmlMimeType, which supports specifying the content type, but .NET ignores this information.
Example: Mapping java.awt.Image without @XmlMimeType
//-- Java code fragment
public class Claim{
public java.awt.I
//-- Schema fragment
&xs:complexType name=&claim&&
&xs:sequence&
&xs:element name=&photo& type=&xs:base64Binary&
minOccurs=&0&/&
&/xs:sequence&
&/xs:complexType&
//-- .NET auto generated code from schema
public partial class claim : object,
System.Runtime.Serialization.IExtensibleDataObject
private byte[] photoF
//-- ..... other gernerated code .......
public byte[] photo
get { return this.photoF }
set { this.photoField = }
//-- C# code fragment
claim tmpC = new claim();
System.IO.FileStream f = new System.IO.FileStream(
&C:\\icons\\circleIcon.gif&, System.IO.FileMode.Open);
int cnt = (int)f.L
tmpC.photo = new byte[cnt];
int rCnt = f.Read(tmpC.photo, 0, cnt);
catch (Exception e)
Console.WriteLine(e.ToString());
Example: Mapping java.awt.Image with @XmlMimeType
//-- Java code fragment
public class Claim{
@XmlMimeType(&image/gif&)
public java.awt.I
//-- Schema fragment
&xs:complexType name=&claim&&
&xs:sequence&
&xs:element name=&photo& ns1:expectedContentTypes=&image/
type=&xs:base64Binary& minOccurs=&0&
xmlns:ns1=&http://www.w3.org/2005/05/xmlmime&/&
&/xs:sequence&
&/xs:complexType&
//-- Using the @XmlMimeType annotation doesn't change .NET
//--auto generated code
public partial class claim : object,
System.Runtime.Serialization.IExtensibleDataObject
private byte[] photoF
//-- ..... other gernerated code .......
public byte[] photo
get { return this.photoF }
set { this.photoField = }
//-- This code is unchanged by the different schema
//-- C# code fragment
claim tmpC = new claim();
System.IO.FileStream f = new System.IO.FileStream(
&C:\\icons\\circleIcon.gif&, System.IO.FileMode.Open);
int cnt = (int)f.L
tmpC.photo = new byte[cnt];
int rCnt = f.Read(tmpC.photo, 0, cnt);
catch (Exception e)
Console.WriteLine(e.ToString());
Guideline: Use java.xml.datatype.XMLGregorianCalendar instead of java.util.Date and java.util.Calendar.
XMLGregorianCalendar supports the following XML schema calendar types: xs:date, xs:time, xs:dateTime, xs:gYearMonth, xs:gMonthDay, xs:gYear, xs:gMonth, and xs:gDay. It is statically mapped to xs:anySimpleType, the common schema type from which all the XML schema calendar types are dervived.
.NET maps xs:anySimpleType to System.string.
java.util.Date and java.util.Calendar map to xs:dateTime, but don't provide as complete XML support as XMLGregorianCalendar does.
Guideline: Use annotation @XmlSchemaType for a strongly typed binding of XMLGregorianCalendar to one of the XML schema calendar types.
Example: XmlGregorianCalendar without @XmlSchemaType
//-- Java code fragment
public class PurchaseOrder{
public javax.xml.datatype.XMLGregorianCalendar orderD
//-- Schema fragment
&xs:complexType name=&purchaseOrder&&
&xs:sequence&
&xs:element name=&orderDate& type=&xs:anySimpleType&
minOccurs=&0&/&
&/xs:sequence&
&/xs:complexType&
//-- .NET auto generated code from schema
public partial class purchaseOrder
private string orderDateF
public string orderDate
get { return this.orderDateF }
set { this.orderDateField = }
//-- C# code fragment
purchaseOrder tmpP = new purchaseOrder();
tmpP.orderDate = System.Xml.XmlConvert.ToString(
System.DateTime.Now,
System.Xml.XmlDateTimeSerializerMode.RoundtripKind);
Example: XMLGregorianCalendar with @XmlSchemaType
//-- Java code fragment
public class PurchaseOrder{
@XmlSchemaType(name=&dateTime&)
public javax.xml.datatype.XMLGregorianCalendar orderD
//-- Schema fragment
&xs:complexType name=&purchaseOrder&&
&xs:sequence&
&xs:element name=&orderDate& type=&xs:dateTime&
minOccurs=&0&/&
&/xs:sequence&
&/xs:complexType&
//-- .NET auto generated code from schema
public partial class purchaseOrder : object,
System.Runtime.Serialization.IExtensibleDataObject
private System.Runtime.Serialization.ExtensionDataObject
extensionDataF
private System.DateTime orderDateF
public System.Runtime.Serialization.ExtensionDataObject
ExtensionData
get { return this.extensionDataF }
set { this.extensionDataField = }
public System.DateTime orderDate
get { return this.orderDateF }
set { this.orderDateField = }
//-- C# code fragment
purchaseOrder tmpP = new purchaseOrder();
tmpP.orderDate = System.DateTime.N
Guideline: Use Leach-Salz variant of UUID at runtime.
java.util.UUID maps to schema type xs:string. .NET maps xs:string to System.string. The constructors in java.util.UUID allow any variant of UUID to be created. Its methods are for manipulation of the Leach-Salz variant.
Example: Mapping UUID
//-- Java code fragment
public class ReportUid{
public java.util.UUID
//-- Schema fragment
&xs:complexType name=&reportUid&&
&xs:sequence&
&xs:element name=&uuid& type=&xs:string& minOccurs=&0&/&
&/xs:sequence&
&/xs:complexType&
//-- .NET auto generated code from schema
public partial class reportUid: object,
System.Runtime.Serialization.IExtensibleDataObject
private System.Runtime.Serialization.ExtensionDataObject
extensionDataF
private string uuidF
public System.Runtime.Serialization.ExtensionDataObject
ExtensionData
get { return this.extensionDataF }
set { this.extensionDataField = }
public string uuid
get { return this.uuidF }
set { this.uuidField = }
//-- C# code fragment
reportUid tmpU = new reportUid();
System.Guid guid = new System.Guid(&06b-4c14-b7fa-
822e2aa6053f&);
tmpU.uuid = guid.ToString();
A typed variable maps to xs:anyType. .NET maps xs:anyType to System.Object.
Example: Using a typed variable
// Java class
public class Shape &T&
&&private T
&&public Shape() {};
&&public Shape(T f)
&&&&xshape =
&xs:complexType name=&shape&&
&&&xs:sequence&
&&&&&xs:element name=&xshape& type=&xs:anyType&
minOccurs=&0&/&
&&&/xs:sequence&
&/xs:complexType&
// C# code generated by svcutil
public partial class shape
&&private object xshapeF
&&public object xshape
&&&&get { return this.xshapeF }
&&&&set { this.xshapeField = }
Java collections types - java.util.Collection and its subtypes, array, List, and parameterized collection types (e.g. List&Integer&) can be mapped to XML schema in different ways and can be serialized in different ways. The following examples show .NET bindings.
By default, a collection type such as List&Integer& maps to a XML schema construct that is a repeating unbounded occurrence of an optional and nillable element. .NET binds the XML schema construct to System.Nullable&int&[]. The element is optional and nillable. However, when marshalling JAXB marshaller will always marshal a null value using xsi:nil.
Example: Collection to a list of nillable elements
//-- Java code fragment
@XmlRootElement(name=&po&)
public PurchaseOrder {
&&public List&Integer&
//-- Schema fragment
&xs:element name=&po& type=&purchaseOrder&&
&xs:complexType name=&purchaseOrder&&
&&&xs:sequence&
&&&&&xs:element name=&items& type=&xs:int& nillable=&true&
&&&&&&&&&&&& minOccurs=&0& maxOccurs=&unbounded&/&
&&&/xs:sequence&
&/xs:complexType&
//--- JAXB XML serialization
&&&items& 1 &/items&
&&&items& 2 &/items&
&&&items& 3 &/items&
&&&items& 1 &/items&
&&&items xsi:nil=true/&
&&&items& 3 &/items&
//-- .NET auto generated code from schema
partial class purchaseOrder {
&&private System.Nullable&int&[] itemsF
&&public System.Nullable&int&[] items
&&&&get { return this.itemsF }
&&&&set { this.itemsField = }&&
This is the same as above except that a collection type such as List&Integer& maps to a repeating unbounded occurrence of an optional (minOccurs=&0&) but not nillable element. This in turn binds to .NET type int[]. This is more developer friendly. However, when marshalling, JAXB will marshal a null value within the List&Integer& as a value that is absent from the XML instance.
Example: Collection to a list of optional elements
//-- Java code fragment
@XmlRootElement(name=&po&)
public PurchaseOrder {
&&@XmlElement(nillable=false)
&&public List&Integer&
//-- Schema fragment
&xs:element name=&po& type=&purchaseOrder&&
&xs:complexType name=&purchaseOrder&&
&&&xs:sequence&
&&&&&xs:element name=&items& type=&xs:int&
&&&&&&&&&&&& minOccurs=&0& maxOccurs=&unbounded&/&
&&&/xs:sequence&
&/xs:complexType&
// .NET auto generated code from schema
partial class purchaseOrder {
&&private int[] itemsF
&&public int[] items
&&&&get { return this.itemsF }
&&&&set { this.itemsField = }&&
A collection such as List&Integer& can be mapped to a list of XML values (i.e. a XML schema list simple type) using annotation @XmlList. .NET maps list simple type to a .NET System.string.
Example: Collection to a list of values using @XmlList
//-- Java code fragment
@XmlRootElement(name=&po&)
public PurchaseOrder {
&&@XmlList public List&Integer&
//-- Schema fragment
&xs:element name=&po& type=&purchaseOrder&&
&xs:complexType name=&purchaseOrder&&
&&&xs:element name=&items& minOccurs=&0&&
&&&&&xs:simpleType&
&&&&&&&xs:list itemType=&xs:int&/&
&&&&&/xs:simpleType&
&&&/xs:element&
&/xs:complexType&
//-- XML serialization
&&&items& 1 2 3 &/items&
// .NET auto generated code from schema
partial class purchaseOrder {
&&private string itemsF
&&public string items
&&&&get { return this.itemsF }
&&&&set { this.itemsField = }
Example: Single and multidimensional Arrays
//-- Java code fragment
public class FamilyTree {
&&public Person[]
&&public Person[][]
// .NET auto generated code from schema
public partial class familyTree
&&private person[]
&&private person[][]
&&public person[] persons
&&&&get { return this.membersF }
&&&&set { this.membersField = }
&&public person[][] families {
&&&&get { return this.familiesF }
&&&&set { this.familiesField = }
The following guidelines apply to mapping of Javabean properties and Java fields, but for brevity Java fields are used.
The @XmlElement annotation maps a property/field to an XML element. This is also the default mapping in the absence of any other JAXB 2.0 annotations. The annotation parameters in @XmlElement can be used to specify whether the element is optional or required, nillable or not. The following examples illustrate the corresponding bindings in the .NET client.
Example: Map a field/property to a nillable element
//-- Java code fragment
public class PurchaseOrder {
&&// Map a field to a nillable XML element
&&@javax.xml.bind.annotation.XmlElement(nillable=true)
&&public java.math.BigD
//-- Schema fragment
&xs:complexType name=&purchaseOrder&&
&&&xs:sequence&
&&&&&xs:element name=&price& type=&xs:decimal&
&&&&&&&&&&&&&&nillable=&true& minOccurs=&0& /&
&&&/xs:sequence&
&/xs:complexType&
// .NET auto generated code from schema
public partial class purchaseOrder {
&&private System.Nullable&decimal& priceF
&&private bool priceFieldS
&&public decimal price
&&&&get { return this.priceF }
&&&&set { this.priceField = }
&&public bool priceSpecified {
&&&&get { return this.priceFieldS }
&&&&set { this.priceFieldSpecified =}
Example: Map property/field to a nillable, required element
//-- Java code fragment
public class PurchaseOrder {
&&// Map a field to a nillable XML element
&&@XmlElement(nillable=true, required=true)
&&public java.math.BigD
//-- Schema fragment
&xs:complexType name=&purchaseOrder&&
&&&xs:sequence&
&&&&&xs:element name=&price& type=&xs:decimal&
&&&&&&&&&&&&&&nillable=&true& minOccurs=&1& /&
&&&/xs:sequence&
&/xs:complexType&
// .NET auto generated code from schema
public partial class purchaseOrder {
&&private System.Nullable&decimal& priceF
&&public decimal price
&&&&get { return this.priceF }
&&&&set { this.priceField = }
A property/field can be mapped to an XML attribute using @XmlAttribute annotation. .NET binds an XML attribute to a property.
Example: Mapping field/property to XML attribute
//-- Java code fragment
public class UKAddress extends Address {
&&@XmlAttribute
&&public int exportC
//-- Schema fragment
&! XML Schema fragment --&
&xs:complexType name=&ukAddress&&
&&&xs:complexContent&
&&&&&xs:extension base=&tns:address&&
&&&&&&&xs:sequence/&
&&&&&&&xs:attribute name=&exportCode& type=&xs:int&/&
&&&&&/xs:extension&
&&&/xs:complexContent&
&/xs:complexType&
// .NET auto generated code from schema
public partial class ukAddress : address
&&private int exportCodeF
&&public int exportCode
&&&&get { return this.exportCodeF }
&&&&set { this.exportCodeField = }
Guideline: @XmlElementRefs maps to a xs:choice. This binds to a property with name &item& in the C# class. If there is another field/property named &item& in the Java class, there will be a name clash that .NET will resolve by generating name. To avoid the nameclash, either change the name or use customization, for example @XmlElement(name=&foo&).
Example: Mapping a field/property using @XmlElementRefs
//-- Java code fragment
public class PurchaseOrder {
&&@XmlElementRefs({
&&&&@XmlElementRef(name=&plane&, type=PlaneType.class),
&&&&@XmlElementRef(name=&auto&, type=AutoType.class)})
&&public TransportType shipBy;
@XmlRootElement(name=&plane&)
public class PlaneType extends TransportType {}
@XmlRootElement(name=&auto&)
public class AutoType extends TransportType { }
@XmlRootElement
public class TransportType { ... }
//-- Schema fragment
&!-- XML schema generated by wsgen --&
&xs:complexType name=&purchaseOrder&&
&&&xs:choice&
&&&&&xs:element ref=&plane&/&
&&&&&xs:element ref=&auto&/&
&&&/xs:choice&
&/xs:complexType&
&!-- XML global elements --&
&xs:element name=&plane& type=&autoType& /&
&xs:element name=&auto& type=&planeType& /&
&xs:complexType name=&autoType&&
&&&!-- content omitted - details not relevant to example --&
&/xs:complexType&
&/xs:complexType name=&planeType&&
&&&!-- content omitted - details not relevant to example --&
&/xs:complexType&
// .NET auto generated code from schema
public partial class purchaseOrder {
&& private transportType itemF
&&[System.Xml.Serialization.XmlElementAttribute(&auto&,
typeof(autoType), Order=4)]
&&[System.Xml.Serialization.XmlElementAttribute(&plane&,
typeof(planeType), Order=4)]
&&public transportType Item
&&&&get { return this.itemF }
&&&&set { this.itemField = }
public partial class planeType { ... } ;
public partial class autoType { ... } ;
A Java class can be mapped to different XML schema type and/or an XML element. The following guidelines apply to the usage of annotations at the class level.
Guideline: Prefer mapping class to named XML schema type rather than an anonymous type for a better .NET type binding.
The @XmlType annotation is used to customize the mapping of a Java class to an anonymous type. .NET binds an anonymous type to a .NET class - one per reference to the anonymous type. Thus, each Java class mapped to an anonymous type can generate multiple classes on the .NET client.
Example: Mapping a Java class to an anonymous type using @XmlType
//-- Java code fragment
public class PurchaseOrder {
&&&&public java.util.List&Item&
@XmlType(name=&&)
public class Item {
&&public String productN
//-- Schema fragment
&xs:complexType name=&purchaseOrder&&
&&&xs:sequence&
&&&&&xs:element name=&item&&
&&&&&&&xs:complexType&
&&&&&&&&&xs:sequence&
&&&&&&&&&&&xs:element name=&productName& type=&xs:string&/&
&&&&&&&&&/xs:sequence&
&&&&&&&/xs:complexType&
&&&&&/xs:element&
&&&/xs:sequence&
&/xs:complexType&
// C# code generated by svcutil
public partial class purchaseOrder
&&&&private purchaseOrderItem[] itemF
&&&&System.Xml.Serialization.XmlElementAttribute(&item&,
Form=System.Xml.Schema.XmlSchemaForm.Unqualified,
IsNullable=true, Order=0)]
&&&&public purchaseOrderItem[] item
&&&&&&get {
&&&&&&&&return this.itemF
&&&&&&set {
&&&&&&&&this.itemField =
// .NET auto generated code from schema
&&public partial class purchaseOrderItem
&&&&private string productNameF
&&&&&&public string productName {
&&&&&&&&get { return this.productNameF }
&&&&&&&&set { this.productNameField = }
Guideline: Avoid using XmlType(propOrder=:{}).
@XmlType(propOrder={}) maps a Java class to a XML Schema complex type with xs:all content model. Since XML Schema places severe restrictions on xs:all, the use of @XmlType(propOrder={}) is therefore not recommended. So, the following example shows the mapping of a Java class to xs:all, but the corresponding .NET code generated by svcutil is omitted.
Example: Mapping a class to xs:all using @XmlType
//-- Java code fragment
@XmlType(propOrder={})
public class USAddress {
&&public S
&&public S
//-- Schema fragment
&xs:complexType name=&USAddress&&
&&&xs:all&
&&&&&xs:element name=&name& type=&xs:string&/&
&&&&&xs:element name=&street& type=&xs:string&/&
&&&/xs:all&
&/xs:complexType&
Guideline: A class can be mapped to a complexType with a simpleContent using @XmlValue annotation. .NET binds the Java property annotated with @XmlValue to a property with name &value&.
Example: Class to complexType with simpleContent
//-- Java code fragment
public class InternationalPrice
&&@XmlValue
&&public java.math.BigD
&&@XmlAttribute public S
//-- Schema fragment
&xs:complexType name=&internationalPrice&&
&&&xs:simpleContent&
&&&&&xs:extension base=xs:decimal&&
&&&&&&xs:attribute name=&currency& type=&xs:string&/&
&&&&&/xs:extension&
&&&/xs:simpleContent&
&/xs:complexType&
// .NET auto generated code from schema
public partial class internationalPrice
&&private string currencyF
&&private decimal valueF
&&public string currency
&&&&get { return this.currencyF }
&&&&set { this.currencyField =}
&&public decimal Value
&&&&get { return this.valueF }
&&&&set { this.valueField =}
JAXB 2.0 supports the following annotations for defining open content. (Open content allows content not statically defined in XML schema to occur in an XML instance):
@XmlAnyElement - which maps to xs:any, which binds to .NET type System.Xml.XmlElement[].
@XmlAnyAttribute - which maps to xs:anyAttribute, which binds to .NET type System.Xml.XmlAttribute[].
Example: Using @XmlAnyElement for open content
//-- Java code fragment
@XmlType(propOrder={&name&, &age&, &oc&})
public class OcPerson {
&&@XmlElement(required=true)
&&public S
&&// Define open content
&&@XmlAnyElement
&&public List&Object&
//-- Schema fragment
&xs:complexType name=&ocPerson&&
&&&xs:sequence&
&&&&&xs:element name=&name& type=&xs:string&/&
&&&&&xs:element name=&age& type=&xs:int&/&
&&&&&xs:any minOccurs=&0& maxOccurs=&unbounded&&
&&&/xs:sequence&
&/xs:complexType&
// .NET auto generated code from schema
public class ocPerson
&&private S
&&private System.Xml.XmlElement[] anyF&
&&public String name { ... }
&&public int age { ... }
&&public System.Xml.XmlElement[] Any {
&&&&get { return this.anyF }
&&&&set { this.anyField = }
Example: Open content using @XmlAnyAttribute
//-- Java code fragment
@XmlType(propOrder={&name&, &age&}
public class OcPerson {
&&public S
&&// Define open content
&&@XmlAnyAttribute
&&public java.util.M
//-- Schema fragment
&xs:complexType name=&ocPerson&&
&&&xs:sequence&
&&&&&xs:element name=&name& type=&xs:string&/&
&&&&&xs:element name=&age& type=&xs:int&/&
&&&/xs:sequence&
&&&xs:anyAttribute/&
&/xs:complexType&
// .NET auto generated code from schema
public class ocPerson
&&private S
&&private System.Xml.XmlAttribute[] anyAttrF&
&&public String name { ... }
&&public double age { ... }
&&public System.Xml.XmlElement[] anyAttr {
&&&&get { return this.anyAttrF }
&&&&set { this.anyAttrField = }
A Java enum type maps to an XML schema type constrained by enumeration facets. This, in turn, binds to .NET type enum type.
Example: Java enum -& xs:simpleType (with enum facets) -& .NET enum
//-- Java code fragment
public enum USState {MA, NH}
//-- Schema fragment
&xs:simpleType name=&usState&&
&&&xs:restriction base=&xs:string&&
&&&&&xs:enumeration value=&NH& /&
&&&&&xs:enumeration value=&MA& /&
&&&/xs:restriction&
&/xs:simpleType&
// .NET auto generated code from schema
public enum usState { NH, MA }
The following package level JAXB annotations are relevant from an interoperability standpoint:
@XmlSchema - customizes the mapping of package to XML namespace.
@XmlSchemaType - customizes the mapping of XML schema built-in type. The @XmlSchemaType annotation can also be used at the property/field level, as was seen in the previous example .
A package is mapped to an XML namespace. The following attributes of the XML namespace can be customized using the @XmlSchema annotation parameters:
elementFormDefault using @XmlSchema.elementFormDefault()
attributeFormDefault using @XmlSchema.attributeFormDefault()
targetNamespace using @XmlSchema.namespace()
Associate namespace prefixes with the XML namespaces using the @XmlSchema.ns() annotation
These XML namespace attributes are bound to .NET serialization attributes (for example, XmlSerializer attributes).
Any JAXB 2.0 annotation can be used but the following are not recommended:
The javax.xml.bind.annotation.XmlElementDecl annotation is used to provide complete XML schema support.
The @XmlID and @XmlIDREF annotations are used for XML object graph serialization, which is not well supported.

我要回帖

更多关于 not 并非 的文章

 

随机推荐