[xsde-users] Working with porly formed legacy xml

Fitzsimmons, Eric EFitzsimmons at cantorgaming.com
Fri Nov 7 13:56:48 EST 2008


I have some legacy code that has a circular dependency between the parsers within the xml.  I've seen the file per type information and have run the command to generate these classes, but I still don't see how it solves this problem.
Here is an example of what the xml looks like.

//////////////////////start XML////////////////////////
<object name="Person" id="1">
  <field type="name" value="SomeName" />
  <field type="age" value="35" />
  <field type="jobs">
    <array>
      <object name="Job" id="1">
        <field type="firstJob" value="true" />
        <field type="Addresses">
          <array>
            <field value="some address" />
          </array>
      </object>
    </array>
</object>
///////////////////////end XML//////////////////////////

The schema for this looks like..

//////////////////////start XSD/////////////////////////
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  <xs:element name="object">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="field"/>
      </xs:sequence>
      <xs:attribute name="id" use="required" type="xs:integer"/>
      <xs:attribute name="name" use="required" type="xs:NCName"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="field">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" ref="array"/>
      </xs:sequence>
      <xs:attribute name="type" type="xs:NCName"/>
      <xs:attribute name="value" type="xs:NMTOKEN"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="array">
    <xs:complexType>
      <xs:choice>
        <xs:element ref="field"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" ref="object"/>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>
///////////////////////end XSD//////////////////////////


Now when I generate the code I get 3 pskel classes, object, field, and array.
Fields have array and arrays have fields, so when I generate an array or field parser it goes into a creating loop or creating the other type.  Is there a way to lazy load this, or is there a way for me to specify in the xsd a way to parse a(this) particular xml?  I know the xml is very difficult to work with and could be done easily if the server could return well-formed xml, but at this point in time, there is no way for us to do that.  If someone could provide me with a brief example, or point me to one I may have missed that addresses this issue I would greatly appreciate it.  Thanks.

This e-mail is confidential. If you are not named above as an addressee or are not the intended recipient of this e-mail, please notify the sender and immediately delete it. 
E-mails are susceptible to data corruption, interception, falsification, delay, unauthorised amendment and viruses. You should therefore carry out such virus and other checks as you consider appropriate. Cantor Gaming does not accept liability for any such events or any consequences thereof in respect of e-mails sent or received. Copyright and any other intellectual property rights in its contents are the sole property of Cantor Gaming. 
The contents of e-mails may be monitored for security purposes. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Cantor Gaming.
This email was sent to you by Cantor Gaming. Cantor Gaming is the trading name of Cantor G&W Nevada L.P., a Nevada limited partnership with offices located at 135 East 57th Street, New York, New York 10022, and Cantor G&W International L.P., a limited partnership registered in England (registered number LP010479) with registered office One Churchill Place, Canary Wharf, London E14 5RD.


More information about the xsde-users mailing list