XmlArrayItemAttribute.Form Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets a value that indicates whether the name of the generated XML element is qualified.
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
Property Value
One of the XmlSchemaForm values. The default is XmlSchemaForm.None
.
Exceptions
Examples
The following example sets the Form property for the Vehicle
class to XmlSchemaForm.Unqualified
, and the Form property for the Car
class to XmlSchemaForm.Qualified
.
public ref class Vehicle
{
public:
String^ id;
};
public ref class Car: public Vehicle
{
public:
String^ Maker;
};
public ref class Transportation
{
public:
// Specifies the Form property value.
[XmlArray("Vehicles")]
[XmlArrayItem(Vehicle::typeid,
Form=XmlSchemaForm::Unqualified),
XmlArrayItem(Car::typeid,
Form=XmlSchemaForm::Qualified)]
array<Vehicle^>^MyVehicles;
};
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
Remarks
The Form property determines whether an XML element name is qualified, based on the World Wide Web Consortium specification Namespaces in XML.
If the Namespace property is set to any value, attempting to set the Form property to XmlSchemaForm.Unqualified
throws an exception.
The default value, XmlSchemaForm.None
, instructs the XmlSerializer to check the schema for the XML document to determine whether the namespace is qualified. For elements, the XmlSerializer checks the value of the schema-element attribute elementFormDefault
. For attributes, it checks the value of the schema-element attribute attributeFormDefault
. For example, the following XML Schema indicates that the Name
element is qualified, while the Number
element is unqualified.
<schema elementFormDefault="qualified"
attributeFormDefault="unqualified">
<element name="Name"/>
<attribute name="Number"/>
</schema>
Applies to
.NET