Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

xmladapter stumbles on schema

Status
Not open for further replies.

rpeduzzi

MIS
Nov 1, 2000
2
US
Hi,

I'm trying to parse an xml response from whitepages.com using VFP 9's xmladapter. I've saved their schema locally as an xsd file. After retrieving the xml using MSXML, I call the adapter with this code:

Code:
o = createobject("xmladapter")
o.RespectNesting = .T.
o.XMLSchemaLocation="whitepages.xsd"
lcXML = ohttp.responsetext
? o.LoadXML(lcxml,.F.,.T.)

and get an error: "There is a duplicate table 'link' in XML schema" ...

I've gone through the schema line-by-line and there are, indeed, two [ref="wp:link"] statements. In all, there are 53 occurrences of 'ref=', but this is the only one that appears twice. I'm guessing this is the problem, but I don't know how to fix it.

Here's the schema (below) ... if anyone has an idea of how it can be made to work, I'd appreciate it!

Thanks (very much),
Rick

Code:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema"[/URL] elementFormDefault="qualified"
		attributeFormDefault="qualified"
		targetNamespace="[URL unfurl="true"]http://api.whitepages.com/schema/"[/URL]
		xmlns:wp="[URL unfurl="true"]http://api.whitepages.com/schema/">[/URL]
    <xs:element name="wp">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="wp:result"/>
                <xs:element minOccurs="0" ref="wp:errormessages"/>
                <xs:element minOccurs="0" ref="wp:meta"/>
                <xs:element minOccurs="0" ref="wp:listings"/>
                <xs:element minOccurs="0" ref="wp:options"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="result">
        <xs:complexType>
            <xs:attribute name="code" use="required" type="wp:responsecode"/>
            <xs:attribute name="message"/>
            <xs:attribute name="type" use="required" type="wp:responsetype"/>
        </xs:complexType>
    </xs:element>
    <xs:simpleType name="responsetype">
        <xs:restriction base="xs:string">
            <xs:enumeration value="success"/>
            <xs:enumeration value="error"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="responsecode">
        <xs:restriction base="xs:string">
            <xs:enumeration value="Found Data"/>
            <xs:enumeration value="No Data Found"/>
            <xs:enumeration value="Truncated Data"/>
            <xs:enumeration value="Error"/>
            <xs:enumeration value="Server Error"/>
            <xs:enumeration value="Invalid Input"/>
            <xs:enumeration value="Mismatched Input"/>
            <xs:enumeration value="Missing Input"/>
            <xs:enumeration value="Refine Input"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:element name="errormessages">
        <xs:complexType>
            <xs:sequence>
                <xs:element maxOccurs="unbounded" ref="wp:message"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="message" type="xs:string"/>
    <xs:element name="meta">
        <xs:complexType>
            <xs:sequence>
                <xs:element minOccurs="0" ref="wp:linkexpiration"/>
                <xs:element ref="wp:recordrange"/>
                <xs:element ref="wp:apiversion"/>
                <xs:element ref="wp:searchlinks"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="linkexpiration" type="xs:date"/>
    <xs:element name="recordrange">
        <xs:complexType>
            <xs:attribute name="lastrecord" use="required" type="xs:integer"/>
            <xs:attribute name="firstrecord" use="required" type="xs:integer"/>
            <xs:attribute name="totalavailable" use="required" type="xs:integer"/>
        </xs:complexType>
    </xs:element>
    <xs:element name="apiversion" type="xs:string"/>
    <xs:element name="searchlinks">
        <xs:complexType>
            <xs:sequence>
                <xs:element maxOccurs="unbounded" ref="wp:link"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="listings">
        <xs:complexType>
            <xs:sequence>
                <xs:element minOccurs="0" maxOccurs="unbounded" ref="wp:listing"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="listing">
        <xs:complexType>
            <xs:sequence>
                <xs:element minOccurs="0" maxOccurs="unbounded" ref="wp:people"/>
                <xs:element minOccurs="0" maxOccurs="unbounded" ref="wp:business"/>
                <xs:element minOccurs="0" ref="wp:phonenumbers"/>
                <xs:element minOccurs="0" ref="wp:address"/>
                <xs:element minOccurs="0" ref="wp:geodata"/>
                <xs:element minOccurs="0" ref="wp:listingmeta"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="people">
        <xs:complexType>
            <xs:sequence>
                <xs:element maxOccurs="unbounded" ref="wp:person"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="person">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="wp:firstname"/>
                <xs:element minOccurs="0" ref="wp:middlename"/>
                <xs:element ref="wp:lastname"/>
                <xs:element minOccurs="0" ref="wp:suffix"/>
            </xs:sequence>
            <xs:attribute name="rank" use="required" type="wp:rank"/>
        </xs:complexType>
    </xs:element>

    <xs:simpleType name="rank">
        <xs:restriction base="xs:string">
            <xs:enumeration value="primary"/>
            <xs:enumeration value="secondary"/>
            <xs:enumeration value="tertiary"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:element name="firstname" type="xs:string"/>
    <xs:element name="middlename" type="xs:string"/>
    <xs:element name="lastname" type="xs:string"/>
    <xs:element name="suffix" type="xs:string"/>
    <xs:element name="business">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="wp:businessname"/>
            </xs:sequence>
            <xs:attribute name="rank" use="required" type="wp:rank"/>
        </xs:complexType>
    </xs:element>
    <xs:element name="businessname" type="xs:string"/>
    <xs:element name="phonenumbers">
        <xs:complexType>
            <xs:sequence>
                <xs:element maxOccurs="unbounded" ref="wp:phone"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="phone">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="wp:fullphone"/>
                <xs:element minOccurs="0" ref="wp:areacode"/>
                <xs:element ref="wp:exchange"/>
                <xs:element ref="wp:linenumber"/>
                <xs:element minOccurs="0" ref="wp:carrier"/>
            </xs:sequence>
            <xs:attribute name="rank" use="required" type="wp:rank"/>
            <xs:attribute name="type" use="required" type="wp:listingtype"/>
            <xs:attribute name="carrier_only"        type="xs:boolean"/>
        </xs:complexType>
    </xs:element>

    <xs:simpleType name="listingtype">
        <xs:restriction base="xs:string">
            <xs:enumeration value="work"/>
            <xs:enumeration value="home"/>
            <xs:enumeration value="business"/>
            <xs:enumeration value="government"/>
            <xs:enumeration value="mobile"/>
            <xs:enumeration value="landline"/>
            <xs:enumeration value="pager"/>
            <xs:enumeration value="satellite"/>
            <xs:enumeration value="unknown"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:element name="fullphone" type="xs:string"/>
    <xs:element name="areacode" type="xs:string"/>
    <xs:element name="exchange" type="xs:string"/>
    <xs:element name="linenumber" type="xs:string"/>
    <xs:element name="carrier" type="xs:string"/>
    <xs:element name="address">
        <xs:complexType>
            <xs:sequence>
                <xs:element minOccurs="0" ref="wp:fullstreet"/>
                <xs:element minOccurs="0" ref="wp:house"/>
                <xs:element minOccurs="0" ref="wp:predir"/>
                <xs:element minOccurs="0" ref="wp:street"/>
                <xs:element minOccurs="0" ref="wp:postdir"/>
                <xs:element minOccurs="0" ref="wp:streettype"/>
                <xs:element minOccurs="0" ref="wp:aptnumber"/>
                <xs:element minOccurs="0" ref="wp:apttype"/>
                <xs:element minOccurs="0" ref="wp:city"/>
                <xs:element minOccurs="0" ref="wp:state"/>
                <xs:element minOccurs="0" ref="wp:zip"/>
                <xs:element minOccurs="0" ref="wp:zip4"/>
                <xs:element minOccurs="0" ref="wp:country"/>
            </xs:sequence>
            <xs:attribute name="deliverable" use="required" type="xs:boolean"/>
        </xs:complexType>
    </xs:element>

    <xs:simpleType name="country">
        <xs:restriction base="xs:string">
            <xs:enumeration value="US"/>
            <xs:enumeration value="CA"/>
        </xs:restriction>
    </xs:simpleType>

    <xs:element name="fullstreet" type="xs:string"/>
    <xs:element name="house" type="xs:string"/>
    <xs:element name="predir" type="xs:string"/>
    <xs:element name="street" type="xs:string"/>
    <xs:element name="postdir" type="xs:string"/>
    <xs:element name="streettype" type="xs:string"/>
    <xs:element name="aptnumber" type="xs:string"/>
    <xs:element name="apttype" type="xs:string"/>
    <xs:element name="city" type="xs:string"/>
    <xs:element name="state" type="xs:string"/>
    <xs:element name="zip" type="xs:string"/>
    <xs:element name="zip4" type="xs:string"/>
    <xs:element name="country" type="wp:country"/>
    <xs:element name="geodata">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="wp:geoprecision"/>
                <xs:element ref="wp:latitude"/>
                <xs:element ref="wp:longitude"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="geoprecision" type="xs:integer"/>
    <xs:element name="latitude" type="xs:string"/>
    <xs:element name="longitude" type="xs:string"/>
    <xs:element name="listingmeta">
        <xs:complexType>
            <xs:sequence>
                <xs:element minOccurs="0" ref="wp:lastvalidated"/>
                <xs:element minOccurs="0" ref="wp:type"/>
                <xs:element ref="wp:moreinfolinks"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="lastvalidated" type="xs:string"/>
    <xs:element name="type" type="wp:listingtype"/>
    <xs:element name="moreinfolinks">
        <xs:complexType>
            <xs:sequence>
                <xs:element minOccurs="0" maxOccurs="unbounded" ref="wp:link"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="options">
        <xs:complexType>
            <xs:sequence>
                <xs:element maxOccurs="unbounded" ref="wp:cityoption"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="cityoption">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="wp:refinesearchurl"/>
            </xs:sequence>
            <xs:attribute name="city" use="required" type="xs:string"/>
            <xs:attribute name="country" use="required" type="wp:country"/>
            <xs:attribute name="state" use="required" type="xs:string"/>
        </xs:complexType>
    </xs:element>
    <xs:element name="refinesearchurl" type="xs:anyURI"/>

    <xs:element name="link">
        <xs:complexType>
            <xs:simpleContent>
                <xs:extension base="xs:anyURI">
                    <xs:attribute name="linktext" use="required" type="xs:string"/>
                    <xs:attribute name="type" use="required" type="wp:linktype"/>
                </xs:extension>
            </xs:simpleContent>
        </xs:complexType>
    </xs:element>
    <xs:simpleType name="linktype">
        <xs:restriction base="xs:string">
            <xs:enumeration value="drivingdirections"/>
            <xs:enumeration value="findneighbors"/>
            <xs:enumeration value="homepage"/>
            <xs:enumeration value="viewdetails"/>
            <xs:enumeration value="viewmap"/>

            <xs:enumeration value="mapareacode"/>

            <xs:enumeration value="allresults"/>
            <xs:enumeration value="mapallresults"/>
            <xs:enumeration value="self"/>
            <xs:enumeration value="worklistings"/>

            <xs:enumeration value="viewsearchsuggestions"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>
 
Hi Again,

Maybe a better way to ask this question is this -- is vfp's xml adapter up to the task (or not)? On the one hand, I know this won't be the last XML I run into (and it would be great to make this work), but maybe it would be better to parse the xml myself ... especially if there's no solution. :)

Nothing I've tried so far has gotten past the error saying there are two tables named 'link' in the schema except when RespectNesting is set to false. When that's the case, vfp generates 20 tables containing some, but not all, of the data in the xml. Worse, though, is that there's nothing in them that would allow linking the data back together ...

So near, yet so far ...

Thank-you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top