Nov 16, 2013 Seems that the serialization scheme is not available or present anymore Try removing SPSS and installing it again using the default folder location, without specifying a different path. Ask Your Own Software Question. TRANSPORTATION CONTROL NUMBER (TCN) A. The TCN is a 17-character data element assigned to control and manage every shipment unit throughout the transportation pipeline and for payment processing. The TCN for each shipment unit is unique and not to be duplicated within the Defense Transportation System (DTS) during.
-->Attributes can be used to control the XML serialization of an object or to create an alternate XML stream from the same set of classes. For more details about creating an alternate XML stream, see How to: Specify an Alternate Element Name for an XML Stream.
Note
If the XML generated must conform to section 5 of the World Wide Web Consortium (W3C) document titled Simple Object Access Protocol (SOAP) 1.1, use the attributes listed in Attributes That Control Encoded SOAP Serialization.
By default, an XML element name is determined by the class or member name. In a simple class named
Book
, a field named ISBN
will produce an XML element tag <ISBN>, as shown in the following example.This default behavior can be changed if you want to give the element a new name. The following code shows how an attribute enables this by setting the ElementName property of a XmlElementAttribute.
For more information about attributes, see Attributes. For a list of attributes that control XML serialization, see Attributes That Control XML Serialization.
Controlling Array Serialization
The XmlArrayAttribute and the XmlArrayItemAttribute attributes are designed to control the serialization of arrays. Using these attributes, you can control the element name, namespace, and XML Schema (XSD) data type (as defined in the World Wide Web Consortium [www.w3.org] document titled 'XML Schema Part 2: Datatypes'). You can also specify the types that can be included in an array.
The XmlArrayAttribute will determine the properties of the enclosing XML element that results when an array is serialized. For example, by default, serializing the array below will result in an XML element named
Employees
. The Employees
element will contain a series of elements named after the array type Employee
.A serialized instance might resemble the following.
By applying a XmlArrayAttribute, you can change the name of the XML element, as follows.
The resulting XML might resemble the following.
The XmlArrayItemAttribute, on the other hand, controls how the items contained in the array are serialized. Note that the attribute is applied to the field returning the array.
The resulting XML might resemble the following.
Serializing Derived Classes
Another use of the XmlArrayItemAttribute is to allow the serialization of derived classes. For example, another class named
Manager
that derives from Employee
can be added to the previous example. If you do not apply the XmlArrayItemAttribute, the code will fail at run time because the derived class type will not be recognized. To remedy this, apply the attribute twice, each time setting the Type property for each acceptable type (base and derived).A serialized instance might resemble the following.
Serializing an Array as a Sequence of Elements
You can also serialize an array as a flat sequence of XML elements by applying a XmlElementAttribute to the field returning the array as follows.
A serialized instance might resemble the following.
Another way to differentiate the two XML streams is to use the XML Schema Definition tool to generate the XML Schema (XSD) document files from the compiled code. (For more details on using the tool, see The XML Schema Definition Tool and XML Serialization.) When no attribute is applied to the field, the schema describes the element in the following manner.
When the XmlElementAttribute is applied to the field, the resulting schema describes the element as follows.
Serializing an ArrayList
The ArrayList class can contain a collection of diverse objects. You can therefore use a ArrayList much as you use an array. Instead of creating a field that returns an array of typed objects, however, you can create a field that returns a single ArrayList. However, as with arrays, you must inform the XmlSerializer of the types of objects the ArrayList contains. To accomplish this, assign multiple instances of the XmlElementAttribute to the field, as shown in the following example.
Controlling Serialization of Classes Using XmlRootAttribute and XmlTypeAttribute
There are two attributes that can be applied to a class (and only a class): XmlRootAttribute and XmlTypeAttribute. These attributes are very similar. The XmlRootAttribute can be applied to only one class: the class that, when serialized, represents the XML document's opening and closing element—in other words, the root element. The XmlTypeAttribute, on the other hand, can be applied to any class, including the root class.
For example, in the previous examples, the
Group
class is the root class, and all its public fields and properties become the XML elements found in the XML document. Therefore, there can be only one root class. By applying the XmlRootAttribute, you can control the XML stream generated by the XmlSerializer. For example, you can change the element name and namespace.The XmlTypeAttribute allows you to control the schema of the generated XML. This capability is useful when you need to publish the schema through an XML Web service. The following example applies both the XmlTypeAttribute and the XmlRootAttribute to the same class.
If this class is compiled, and the XML Schema Definition tool is used to generate its schema, you would find the following XML describing
Group
.In contrast, if you were to serialize an instance of the class, only
NewGroupName
would be found in the XML document.Preventing Serialization with the XmlIgnoreAttribute
There might be situations when a public property or field does not need to be serialized. For example, a field or property could be used to contain metadata. In such cases, apply the XmlIgnoreAttribute to the field or property and the XmlSerializer will skip over it.