Bagikan melalui


XmlArrayItemAttribute.Form Properti

Definisi

Mendapatkan atau menetapkan nilai yang menunjukkan apakah nama elemen XML yang dihasilkan memenuhi syarat.

public:
 property System::Xml::Schema::XmlSchemaForm Form { System::Xml::Schema::XmlSchemaForm get(); void set(System::Xml::Schema::XmlSchemaForm value); };
public System.Xml.Schema.XmlSchemaForm Form { get; set; }
member this.Form : System.Xml.Schema.XmlSchemaForm with get, set
Public Property Form As XmlSchemaForm

Nilai Properti

Salah XmlSchemaForm satu nilai. Defaultnya adalah XmlSchemaForm.None.

Pengecualian

Properti Form diatur ke XmlSchemaForm.Unqualified dan Namespace nilai ditentukan.

Contoh

Contoh berikut mengatur properti untuk Vehicle kelas ke XmlSchemaForm.Unqualified, dan Form properti untuk Car kelas ke XmlSchemaForm.Qualified.Form

public class Transportation
{
   [XmlArray("Vehicles")]
   // Specifies the Form property value.
   [XmlArrayItem(typeof(Vehicle),
   Form = XmlSchemaForm.Unqualified),
   XmlArrayItem(typeof(Car),
   Form = XmlSchemaForm.Qualified)]
   public Vehicle[] MyVehicles;
}

public class Vehicle
{
   public string id;
}

public class Car:Vehicle
{
   public string Maker;
}
Public Class Transportation
    ' Specify the Form property value.
    <XmlArray("Vehicles"), _
     XmlArrayItem(GetType(Vehicle), Form := XmlSchemaForm.Unqualified), _
     XmlArrayItem(GetType(Car), Form := XmlSchemaForm.Qualified)> _
    Public MyVehicles() As Vehicle
End Class

Public Class Vehicle
    Public id As String
End Class

Public Class Car
    Inherits Vehicle
    Public Maker As String
End Class

Keterangan

Properti Form menentukan apakah nama elemen XML memenuhi syarat, berdasarkan Namespace spesifikasi World Wide Web Consortium di XML.

Namespace Jika properti diatur ke nilai apa pun, mencoba mengatur Form properti untuk XmlSchemaForm.Unqualified melemparkan pengecualian.

Nilai default, XmlSchemaForm.None, menginstruksikan XmlSerializer untuk memeriksa skema dokumen XML untuk menentukan apakah namespace layanan memenuhi syarat. Untuk elemen, XmlSerializer memeriksa nilai atribut elementFormDefaultskema-element . Untuk atribut, ini memeriksa nilai atribut attributeFormDefaultskema-element . Misalnya, Skema XML berikut menunjukkan bahwa Name elemen memenuhi syarat, sementara Number elemen tidak memenuhi syarat.

<schema elementFormDefault="qualified"
attributeFormDefault="unqualified">
   <element name="Name"/>
   <attribute name="Number"/>
</schema>

Berlaku untuk