This topic has not yet been rated - Rate this topic

XmlArrayItemAttribute.Form Property

Gets or sets a value that indicates whether the name of the generated XML element is qualified.

Namespace: System.Xml.Serialization
Assembly: System.Xml (in system.xml.dll)

public XmlSchemaForm Form { get; set; }
/** @property */
public XmlSchemaForm get_Form ()

/** @property */
public void set_Form (XmlSchemaForm value)

public function get Form () : XmlSchemaForm

public function set Form (value : XmlSchemaForm)

Not applicable.

Property Value

One of the XmlSchemaForm values. The default is XmlSchemaForm.None.
Exception typeCondition

Exception

The Form property is set to XmlSchemaForm.Unqualified and a Namespace value is specified.

The Form property determines whether an XML element name is qualified, based on the World Wide Web Consortium (www.w3.org) 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>

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 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
{
    /** @attribute XmlArray("Vehicles")
     */
    // Specifies the Form property value.
    /** @attribute XmlArrayItem(Vehicle.class, 
        Form = XmlSchemaForm.Unqualified)
        @attribute XmlArrayItem(Car.class,
        Form = XmlSchemaForm.Qualified)
     */
    public Vehicle myVehicles[];
} //Transportation

public class Vehicle
{
    public String id;
} //Vehicle

public class Car extends Vehicle
{
    public String maker;
} //Car

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0

XNA Framework

Supported in: 1.0
Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.