<rss version="2.0"><channel><title>XML-FX.COM XML-FX.COM Blog</title><item><title><![CDATA[SAIDValidator - South African ID Validator Webservice]]></title><link><![CDATA[http://xml-fx.com:80//Default.aspx?pg=199cc614-2f83-4811-b4be-79cdc39d11b8&detail=33db889b-3b5b-46f9-b605-44d432708aa5#43ed2d30-f7b8-4298-b8e3-bd0732444e3f]]></link><description><![CDATA[<h3 style="text-align: justify;">SAIDValidator - South African ID Validator Webservice</h3>
<p style="text-align: justify;">SAIDValidator is an ASP.NET webservice to validate South African Person ID numbers. It provides validation of a person ID by calculating the check-digit (digit-13), and extracts the date-of-birth, gender, citizenship, sequence and other information.</p>
<p>The following sections provide further information:</p>
<table width="100%" cellspacing="1" cellpadding="1" border="0">
    <tbody>
        <tr>
            <td width="18%"><a href="services/SAIDValidator.aspx">Homepage</a></td>
            <td style="text-align: justify;">SAIDValidator homepage.</td>
        </tr>
        <tr>
            <td width="18%"><a href="services/saidvalidator/documentation.aspx">Documentation</a></td>
            <td style="text-align: justify;">Standard WSDL service description and web method documentation.</td>
        </tr>
        <tr>
            <td><a href="services/saidvalidator/schemas.aspx">Schemas</a></td>
            <td style="text-align: justify;">The XML-schemas for the different object types used as parameters and return values of the webservice methods.</td>
        </tr>
        <tr>
            <td><a href="http://geekswithblogs.net/willemf/archive/2005/10/30/58561.aspx" target="_blank">Blog</a></td>
            <td style="text-align: justify;">The original blog post for more information: <a href="http://geekswithblogs.net/willemf/archive/2005/10/30/58561.aspx" target="_blank">How to validate SA Identity Numbers</a>.</td>
        </tr>
        <tr>
            <td><a href="services/saidvalidator/TestPage.aspx">Test Page</a></td>
            <td style="text-align: justify;">A standard input form that when submitted returns an analysis and validation of the ID number. It calls the <a href="services/saidvalidator/documentation.aspx">SAIDValidator</a> webservice.</td>
        </tr>
    </tbody>
</table>
<p> </p>
<p> </p>]]></description></item><item><title><![CDATA[XML-FX.COM xfxDoc Tool]]></title><link><![CDATA[http://xml-fx.com:80//Default.aspx?pg=199cc614-2f83-4811-b4be-79cdc39d11b8&detail=dcd34e95-c0d9-4daa-870e-22e01dbf0fae#43ed2d30-f7b8-4298-b8e3-bd0732444e3f]]></link><description><![CDATA[<h3 style="text-align: justify;">XML-FX.COM xfxDoc Tool</h3>
<p style="text-align: justify;">The xfxDoc tool documents XML-schemas using the Altova XMLSpy XML-schema documentation format to produce Microsoft HTML Help documentation (.chm) files that feature auto-generated table-of-contents, index, and full-text search.</p>
<h4 style="text-align: justify;">Links</h4>
<ul>
    <li style="text-align: justify;"><a href="tools/xfxdoc.aspx">xfxDoc Homepage</a></li>
    <li style="text-align: justify;"><a href="downloads/tools/xfxdoc.aspx">Download</a> the xfxDoc Tool</li>
    <li style="text-align: justify;"><a href="tools/xfxdoc/help.aspx" target="_blank">Online Help</a></li>
</ul>
<h4 style="text-align: justify;">Motivation</h4>
<p style="text-align: justify;">As the use of XML as the protocol for information interfaces is becoming more common and accepted in the industry, two important facts are emerging:</p>
<ul>
    <li style="text-align: justify;">The W3C consortium XML-schema or  XSD-standard is the major standard for describing the structure and syntax of  XML data.</li>
    <li style="text-align: justify;">More than ever, these XML-schemas are  becoming huge, complex and more resource-intensive, both in human- and computer-  terms.</li>
</ul>
<p style="text-align: justify;">An important part of managing and utilizing large schema sets is to provide comprehensive and easy-to-use documentation describing the schemas. Altova XMLSpy provides a handy capability to do this, in both a Microsoft Word format and an HTML format. The advantage of the HTML documentation is that it can be easily published, as well as providing the following additional important advantages:</p>
<ul>
    <li value="1" style="text-align: justify;">The documentation provides XML-schema structure description using diagrams. The diagram constructs used have become a de-facto industry standard in terms of schema documentation. The HTML page also provides hot-spots within the diagrams that provide easy navigation between schema documentation constructs.</li>
    <li value="2" style="text-align: justify;">The documentation text is easy to  understand and is comprehensive.</li>
    <li value="3" style="text-align: justify;">'Type', 'Used By' and 'Children' sections provide easy navigation around the documentation in terms of parent-child relationships.</li>
    <li value="4" style="text-align: justify;">Most importantly, the documentation is  generated automatically, with very little user intervention.</li>
</ul>
<p style="text-align: justify;">However, when the schema(-sets) get moderately  complex, the HTML documentation is inadequate, for the following reasons:</p>
<ul>
    <li value="1" style="text-align: justify;">The documentation takes the form of a single page, or sets of related pages, the size of which can easily be in excess of a few megabytes. This results in a slower loading page in the browser, the page navigation performance of the loaded page is poor, and the user experience is substantially degraded. For very large schemas, the page is often unable to load and even causes the browser to throw an exception.</li>
    <li value="2" style="text-align: justify;">The documentation has a very simple indexing section at the top of the page, which is not efficient. It has no real table-of-contents, keyword index, or full-text search, which becomes more important as the size of the documentation increases.</li>
</ul>
<h4 style="text-align: justify;">How it works</h4>
<p style="text-align: justify;">The xfxDoc application takes as input the HTML page(s) generated by the XMLSpy XML-schema 'Generate Documentation' command, and outputs a fully-featured compiled HTML Help (.chm) file. Functionality includes:</p>
<ul>
    <li value="1" style="text-align: justify;">Utilizing the XMLSPY documentation  'standard' completely;</li>
    <li value="2" style="text-align: justify;">Automatically executes XMLSPY via the  XMLSPYLIB automation interface and generates documentation according to  user-presets;</li>
    <li value="3" style="text-align: justify;">Splits the generated single HTML  documentation page(s) into separate HTML pages, one page per main topic;</li>
    <li value="4" style="text-align: justify;">Builds an HTML Help table-of-contents (.hhc), and index (.hhk) file automatically from the schema construct type and construct name that it derives from the contents of each page;</li>
    <li value="5" style="text-align: justify;">Rebuilds the HTML image hot-spot and  text hyperlinks automatically to retain the original XMLSPY navigation  capabilities;</li>
    <li value="6" style="text-align: justify;">Uses a user-specified HTML Help project template (with replaceable parameters), to automatically generate the target HTML Help project file (.hhp) which can directly compiled;</li>
    <li value="7" style="text-align: justify;">Automatically executes the Microsoft  HTML Help Compiler (hhc.exe) to build the final .chm help file;</li>
    <li value="8" style="text-align: justify;">Allows further enhancement to the  generated documentation via user-coded plug-in assemblies.</li>
</ul>
<p style="text-align: justify;">The resulting HTML Help file is fully-featured, easy to navigate, and provides great  performance.</p>
<p style="text-align: justify;">xfxDoc is provided as a .NET Windows Forms  application.</p>
<p style="text-align: justify;"> </p>
<p style="text-align: justify;"> </p>]]></description></item><item><title><![CDATA[Using XmlSerializer with external serializable types]]></title><link><![CDATA[http://xml-fx.com:80//Default.aspx?pg=199cc614-2f83-4811-b4be-79cdc39d11b8&detail=4c740d88-e412-4d05-b88f-4bc337fd95b5#43ed2d30-f7b8-4298-b8e3-bd0732444e3f]]></link><description><![CDATA[<h3>Using XmlSerializer with external serializable types</h3>
<ul>
    <li><a href="downloads/blog/post_0001.aspx">Download VS2008 solution, C# projects and full source code</a></li>
</ul>
<h4><a name="TOC" class="bookmark">Table of contents</a></h4>
<div><a href="#Introduction">Introduction</a></div>
<div><a href="#ExtensibleClass">Simple extensible class</a></div>
<div><a href="#ExternalClass">External data class</a></div>
<div><a href="#Test_1">Test #1: Set an instance of the external data class</a></div>
<div><a href="#Test_2">Test #2: Use a proxy serializer class<br />
</a></div>
<div><a href="#Dependencies">Dependencies and Packaging</a></div>
<div><a href="#Test_3">Test #3: A parameterized proxy serializer class</a></div>
<div><a href="#CodeSafety">Code safety</a></div>
<h4><a name="Introduction" class="bookmark">Introduction</a></h4>
<p style="text-align: justify;">Often XML data interfacing or exchange structures are required to be adaptable to changing business and data needs. One solution to this is to provide an <a href="http://www.w3.org/TR/xmlschema-0/#anyType" target="_blank">xs:anyType</a> element to the data, with the idea that this data can be provided by another code class, assembly or even another application as part of the interface realization. The <a href="http://www.w3.org/TR/xmlschema-0/#anyType" target="_blank">xs:anyType</a> element is unconstrained and can contain any valid XML tags and content.</p>
<h4><a name="ExtensibleClass" class="bookmark">Simple extensible class</a></h4>
<p style="text-align: justify;">In Figure 1 below, a simple extensible XML data structure is defined with the extensible unconstrained element represented by the <em>ExternData</em> element in the diagram.</p>
<p align="center"><img width="476" height="358" title="Simple extensible XML data structure" src="/ImageHandler.ashx?UploadedFile=true&pg={0}&image=/App_Data/UserImages/Figure_0001_01.png" alt="Simple extensible XML data structure" class="figure" /><br />
<br />
Figure 1 : A simple extensible XML data structure</p>
<p style="text-align: justify;">If the XML schema represented in Figure 1 above (<em>extdata.xsd</em> in the 'schema' solution folder) is run through an X/O mapper that supports serialization using the .NET <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer%28VS.95%29.aspx" target="_blank">XmlSerializer</a> class (such as Microsoft's <a href="http://msdn.microsoft.com/en-us/library/943242d1%28VS.80%29.aspx" target="_blank">XSD.EXE</a>), the class member generated for the <em>ExternData</em> is of type <span style="color: rgb(0, 0, 255);">System.Object</span> as shown below:</p>
<div id="hlDiv" class="dp-highlighter">
<ol class="dp-c">
    <li class="alt"><span><span>[System.Xml.Serialization.XmlElementAttribute(</span><span class="string">"ExternData"</span><span>)]     </span></span></li>
    <li><span><span class="keyword">public</span><span> </span><span class="keyword">object</span><span> ExternData     </span></span></li>
    <li class="alt"><span>{     </span></li>
    <li><span>    <span class="keyword">get</span><span> { </span><span class="keyword">return</span><span> externData; }     </span></span></li>
    <li class="alt"><span>    <span class="keyword">set</span><span> { externData = value; }     </span></span></li>
    <li><span>}  </span></li>
</ol>
</div>
<p>The complete C# source-code of the serialization class is shown below (<strong>Test_1</strong> : <em>ExtensibleDataType.cs</em>):</p>
<ul>
    <li><a href="defaultpopup.aspx?pg=962fa4ac-414a-4854-b54f-e8000a2c2b76" onclick="window.open(this.href,'DefaultPopup','resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,fullscreen=no,dependent=no,width=720,height=480,status'); return false">Listing 1 : Simple extensible serializable and serialization support class source code</a></li>
</ul>
<h4><a class="bookmark" name="ExternalClass">External data class</a></h4>
<p>Similarly, an XML schema can be defined for the data that is contained in the <em>ExternData</em> element tag. For this example the schema shown in Figure 2 below is used (<em>website.xsd</em> in the 'schema' solution folder):</p>
<p style="text-align: center;"><img width="300" height="250" title="An external XML data structure to be placed in the 'ExternData' element" src="/ImageHandler.ashx?UploadedFile=true&pg={0}&image=/App_Data/UserImages/Figure_0001_02.png" alt="An external XML data structure to be placed in the 'ExternData' element" class="figure" /><br />
<br />
Figure 2 : An external XML data structure to be placed in the 'ExternData' element</p>
<p style="text-align: justify;">Combining XML data based on the schemas in Figures 1 and 2, a sample XML data file can be produced which will validate with the schema in Listing 1 (<em>test.002.xml</em> in the 'schema' solution folder):</p>
<ul>
    <li><a href="defaultpopup.aspx?pg=e9b5419e-5027-48d1-9a1b-1d7222970f52" onclick="window.open(this.href,'DefaultPopup','resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,fullscreen=no,dependent=no,width=720,height=480,status'); return false">Listing 2 : Base and external XML data sample</a></li>
</ul>
<p>The complete C# source-code of the external data serialization class is shown below (<span style="font-weight: bold;">WebsiteData</span> : <em>WebsiteData.cs</em>):</p>
<ul>
    <li><a href="defaultpopup.aspx?pg=af3a8b6a-4f3c-4bbb-aa6c-cb7d01606a30" onclick="window.open(this.href,'DefaultPopup','resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,fullscreen=no,dependent=no,width=720,height=480,status'); return false">Listing 3 : External data class source code</a></li>
</ul>
<h4><a name="Test_1" class="bookmark">Test #1: Set an instance of the external data class </a></h4>
<p style="text-align: justify;">The <strong>Test_1</strong> console application (<em>Test_1.csproj</em>) attempts to read the file <em>test.001.xml</em> which contains the same data as <a href="defaultpopup.aspx?pg=e9b5419e-5027-48d1-9a1b-1d7222970f52" onclick="window.open(this.href,'DefaultPopup','resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,fullscreen=no,dependent=no,width=720,height=480,status'); return false">Listing 2</a> without the additional <em>ExternData </em>element. Since this element does not exist, it is not bound to the <em>ExternData </em>property of the <em>ExtensibleDataType </em>class in <a href="defaultpopup.aspx?pg=962fa4ac-414a-4854-b54f-e8000a2c2b76" onclick="window.open(this.href,'','resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,fullscreen=no,dependent=no,width=720,height=480,status'); return false">Listing 1</a>, and the value of this property is <span style="color: rgb(0, 0, 255);">null</span>. The application then creates a <span style="color: rgb(0, 0, 255);">WebsiteData.Website</span> object and then sets the <em>ExternData </em>property to this object. The application Main() method source-code is shown below (<em>Program.cs</em>):</p>
<ul>
    <li><a href="defaultpopup.aspx?pg=9747787c-0362-4bfd-b860-b6d6bb8c3a7d" onclick="window.open(this.href,'DefaultPopup','resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,fullscreen=no,dependent=no,width=720,height=480,status'); return false">Listing 4 :Application Main() source code</a></li>
</ul>
<p style="text-align: justify;">When the object is subsequently serialized, the <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer%28VS.95%29.aspx" target="_blank">XmlSerializer</a> throws an exception with the following message:</p>
<p style="text-align: justify;">"<span style="color: rgb(153, 51, 102);"><em>The type WebsiteData.Website was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.</em></span>"</p>
<p style="text-align: justify;">This means that the <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer%28VS.95%29.aspx" target="_blank">XmlSerializer</a> could not find the <span style="color: rgb(0, 0, 255);">WebsiteData.Website</span> type definition and therefore was unable to serialize the <em>ExternData </em>object. Although this was not unexpected, it is problematic since the original concept of allowing externally defined data to be injected into the base data is not working.</p>
<p style="text-align: justify;">Two interesting points should be noted:</p>
<ol>
    <li style="text-align: justify;">If the <span style="color: rgb(0, 0, 255);">Website </span>class is moved into the same assembly as the <span style="color: rgb(0, 0, 255);">ExtensibleDataType</span>, the de-/serialization proceeds normally. However, this is still contrary to the whole extensibility concept.</li>
    <li style="text-align: justify;">If the XML file <em>test.002.xml</em> (which contains a valid <span style="color: rgb(0, 0, 255);">Website</span> element) is read instead of <em>test.001.xml,</em> the <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer%28VS.95%29.aspx" target="_blank">XmlSerializer</a> de-serializes it without error, but the <em>ExternData </em>now consists of two <a href="http://msdn.microsoft.com/en-us/library/system.xml.xmlnode.aspx" target="_blank">System.Xml.XmlNode</a> objects which carry the data. Again, this is a problem, since a part of the data is now held in serialization classes (read: domain rich), while another part is held as an XML DOM, which is a model of the XML data structure and format, and not a model of the underlying domain data that serialization classes provide.</li>
</ol>
<h4><a class="bookmark" name="Test_2">Test #2: Use a proxy serializer class</a></h4>
<p style="text-align: justify;">The following principle provides the solution to the problem of Test #1: a proxy object is required which can be triggered by the <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer%28VS.95%29.aspx" target="_blank">XmlSerializer</a> at the correct time to de-serialize data stored in the <em>ExternData </em>element as an XML attribute. This must provide the type information to the <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer%28VS.95%29.aspx" target="_blank">XmlSerializer</a> so that it can instantiate and bind the required external data object when de-serializing the XML data. Obviously the reverse process for serialization should also apply.</p>
<p style="text-align: justify;">Listing 5 below provides the source-code for <span style="color: rgb(0, 0, 255);">ExternDataSerializer</span> which is an example of a proxy serialization class:</p>
<ul>
    <li><a href="defaultpopup.aspx?pg=264a2bb4-bcd7-4ff4-81a2-730f95780cab" onclick="window.open(this.href,'DefaultPopup','resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,fullscreen=no,dependent=no,width=720,height=480,status'); return false">Listing 5 : Proxy serialization class source code</a></li>
</ul>
<p style="text-align: justify;">The following are points of interest in the implementation of the <span style="color: rgb(0, 0, 255);">ExternDataSerializer</span> class:</p>
<ol>
    <li style="text-align: justify;">In order for the class to be triggered by the <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer%28VS.95%29.aspx" target="_blank">XmlSerializer</a> during de-/serialization, the <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.ixmlserializable.aspx" target="_blank">IXmlSerializable</a> interface must be implemented.</li>
    <li style="text-align: justify;">In the <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.ixmlserializable.writexml.aspx" target="_blank">WriteXml</a> method, an attribute with the name 'Type' is written, and its value contains the <a href="http://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname.aspx" target="_blank">AssemblyQualifiedName</a>, which provides sufficient information for the <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer%28VS.95%29.aspx" target="_blank">XmlSerializer</a> to correctly de-/serialize the external class, even if the class is defined in a different assembly.</li>
    <li style="text-align: justify;">In the <a target="_blank" href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.ixmlserializable.readxml.aspx">ReadXml</a> method, the 'Type' attribute is read, the <span style="color: rgb(0, 0, 255);">System.Type</span> of the required external data class is determined, and the <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer%28VS.95%29.aspx" target="_blank">XmlSerializer</a> can instantiate and de-serializer the object correctly.</li>
    <li style="text-align: justify;">The proxy class retains a reference to the external data object created by the <a href="http://msdn.microsoft.com/en-us/library/system.xml.serialization.xmlserializer%28VS.95%29.aspx" target="_blank">XmlSerializer</a>. This is required, as the proxy class has to be implicitly cast from the external type during serialization, and to the external type during de-serialization. This functionality is provided by the two implicit cast methods.</li>
</ol>
<p style="text-align: justify;">So what else has to change in order to get this solution to work? Firstly, the external data type has to derive from a base class that is not of type <span style="color: rgb(0, 0, 255);">System.Object</span>. The reason for this is that the implicit cast operators cannot cast between the <span style="color: rgb(0, 0, 255);">ExternDataSerializer</span> class and <span style="color: rgb(0, 0, 255);">System.Object</span>. In Listing 3 the <span style="color: rgb(0, 0, 255);">Website </span>class now derives from a base class <span style="color: rgb(0, 0, 255);">AppData.Interface.ExternData</span>:</p>
<div id="hlDiv" class="dp-highlighter">
<ol class="dp-c" start="1">
    <li class="alt"><span><span class="keyword">public</span><span> partial </span><span class="keyword">class</span><span> Website : <u><b>AppData.Interface.ExternData</b></u>  </span></span></li>
    <li><span>{  </span></li>
    <li class="alt"><span>  ..  </span></li>
    <li><span>}  </span></li>
</ol>
</div>
<p>The <span style="color: rgb(0, 0, 255);">AppData.Interface.ExternData</span> class is shown below:</p>
<div class="dp-highlighter" id="hlDiv">
<ol start="1" class="dp-c">
    <li class="alt"><span><span class="keyword">namespace</span><span> AppData.Interface  </span></span></li>
    <li><span>{  </span></li>
    <li class="alt"><span>    <span class="keyword">public</span><span> </span><span class="keyword">abstract</span><span> </span><span class="keyword">class</span><span> ExternData { }  </span></span></li>
    <li><span>}  </span></li>
</ol>
</div>
<p style="text-align: justify;">The <span style="color: rgb(0, 0, 255);">AppData.Interface.ExternData</span> class is <span style="color: rgb(0, 0, 255);">abstract</span> and empty. In a real application this class can provide other data which may be required as part of the data contract or interface.</p>
<p style="text-align: justify;">The <span style="color: rgb(0, 0, 255);">ExtensibleDataType class</span> also has to change: first the <span style="color: rgb(0, 0, 255);">externData</span> member has to be of type <span style="color: rgb(0, 0, 255);">AppData.Interface.ExternData</span>:</p>
<div id="hlDiv" class="dp-highlighter">
<ol class="dp-c" start="1">
    <li><span><span class="keyword">private</span><span> <u><strong>AppData.Interface.ExternData</strong></u> externData;  </span></span></li>
</ol>
</div>
<p>The serialization property <span style="color: rgb(0, 0, 255);">ExternData </span>also has to change:</p>
<div id="hlDiv" class="dp-highlighter">
<ol class="dp-c" start="1">
    <li class="alt"><span><span>[System.Xml.Serialization.XmlElementAttribute(</span><span class="string">"ExternData", </span><u><strong><span>Type = </span><span class="keyword">typeof</span><span>(ExtData.ExternDataSerializer</span></strong></u><span>))]  </span></span></li>
    <li><span><span class="keyword">public</span><span> <u><strong>AppData.Interface.ExternData</strong></u> ExternData  </span></span></li>
    <li class="alt"><span>{  </span></li>
    <li><span>    <span class="keyword">get</span><span> { </span><span class="keyword">return</span><span> externData; }  </span></span></li>
    <li class="alt"><span>    <span class="keyword">set</span><span> { externData = value; }  </span></span></li>
    <li><span>}  </span></li>
</ol>
</div>
<p><strong>Test_2</strong> (<em>test_2.csproj</em>) provides the working console application implemented as above.</p>
<h4><a class="bookmark" name="Dependencies">Dependencies and Packaging</a></h4>
<p>Figure 3 below shows a class dependency diagram of the important classes:</p>
<p style="text-align: center;"><img width="592" height="334" title="Main classes and dependencies" src="/ImageHandler.ashx?UploadedFile=true&pg={0}&image=/App_Data/UserImages/Figure_0001_03.png" alt="Main classes and dependencies" class="figure" /><br />
<br />
Figure 3 : Main classes and dependencies</p>
<p style="text-align: justify;">In a real application, it may be prudent to package the <span style="color: rgb(0, 0, 255);">ExternDataSerializer </span>and the <span style="color: rgb(0, 0, 255);">ExternData </span>class in the same assembly. The <span style="color: rgb(0, 0, 255);">ExtensibleDataType </span>is often generated automatically and repeatedly from an XML schema, and should be packaged by itself (or with other <span style="color: rgb(0, 0, 255);">AppData </span>types). The <span style="color: rgb(0, 0, 255);">Website </span>class (which represents all external data types) should be in its own assembly. Note that neither the <span style="color: rgb(0, 0, 255);">Website </span>or the <span style="color: rgb(0, 0, 255);">ExtensibleDataType </span>are directly dependent on each other. The only requirement to add other external data types to the system is to make the external data type a subclass of <span style="color: rgb(0, 0, 255);">ExternData</span>, and to provide a reference to the assembly containing the <span style="color: rgb(0, 0, 255);">ExternData </span>type.</p>
<h4><a name="Test_3">Test #3: A parameterized proxy serializer class</a></h4>
<p><strong>Test_3</strong> (<em>test_3.csproj</em>) provides a similar solution to <strong>Test_2</strong> but using a parameterized (generic) proxy serializer class. The source code is shown in Listing 6 below:</p>
<ul>
    <li><a href="defaultpopup.aspx?pg=c6f28d2e-6097-4220-91c3-23c2e3f0a261" onclick="window.open(this.href,'DefaultPopup','resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,fullscreen=no,dependent=no,width=720,height=480,status'); return false">Listing 6 : Parameterized proxy serialization class source code</a></li>
</ul>
<p>The only other change required is the serialization property <span style="color: rgb(0, 0, 255);">ExternData </span>of the <span style="color: rgb(0, 0, 255);">ExtensibleDataType</span> class:</p>
<div id="hlDiv" class="dp-highlighter">
<ol class="dp-c" start="1">
    <li class="alt"><span><span>[System.Xml.Serialization.XmlElementAttribute(</span><span class="string">"ExternData"</span><span>, Type = </span><u><strong><span class="keyword">typeof</span><span>(ExtData.ExternDataSerializer <AppData.Interface.ExternData></span></strong></u><span>))]  </span></span></li>
</ol>
</div>
<h4><a name="CodeSafety">Code safety</a></h4>
<p>In <a href="defaultpopup.aspx?pg=9747787c-0362-4bfd-b860-b6d6bb8c3a7d" onclick="window.open(this.href,'DefaultPopup','resizable=yes,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no,fullscreen=no,dependent=no,width=720,height=480,status'); return false">Listing 4</a> line 24 and 25 the application has to check if the external data object it is working with is of the type it is expecting. Although this is annoying, it is required since the definition of the schema allows for an instance of any type to be present.</p>
<p> </p>]]></description></item></channel></rss>