Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zillow's SearchResults.xsd and Visual Studio's XSD command

I tried to run Visual Studio's XSD.EXE utility on the zillow "SearchResults.xsd" to generate c# or vb.net classes but am having no luck and am looking for help. I keep getting errors (see below). Here is the original file I downloaded from http://www.zillow.com/howto/api/GetDeepSearchResults.htm:

<?xml version="1.0" encoding="utf-8"?>

<xsd:schema attributeFormDefault="unqualified"
    elementFormDefault="unqualified"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://www.zillow.com/static/xsd/SearchResults.xsd"     
    xmlns:ZillowTypes="http://www.zillow.com/static/xsd/ZillowTypes.xsd">

    <xsd:import namespace="http://www.zillow.com/static/xsd/ZillowTypes.xsd"
    schemaLocation="/vstatic/4/static/xsd/ZillowTypes.xsd"  />

    <xsd:element name="searchresults">
        <xsd:complexType>
            <xsd:sequence>

                <xsd:element name="request">
                    <xsd:complexType>
                        <xsd:sequence>
                            <xsd:element name="address" type="xsd:string" />
                            <xsd:element name="citystatezip" type="xsd:string" />
                        </xsd:sequence>
                    </xsd:complexType>
                </xsd:element>

                <xsd:element name="message" type="ZillowTypes:Message" />

                <xsd:element minOccurs="0" name="response">
                    <xsd:complexType>
                        <xsd:sequence>
                            <xsd:element name="results">
                                <xsd:complexType>
                                    <xsd:sequence>
                                        <xsd:element minOccurs="1" maxOccurs="unbounded" name="result" type="ZillowTypes:SimpleProperty" />
                                    </xsd:sequence>
                                </xsd:complexType>
                            </xsd:element>
                        </xsd:sequence>
                    </xsd:complexType>
                </xsd:element>

            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>

</xsd:schema>

Here are the errors I keep getting when I try XSD.EXE from Visual Studio 2010:

C:\Users\username\Documents>xsd /classes SearchResults.xsd
Microsoft (R) Xml Schemas/DataTypes support utility
[Microsoft (R) .NET Framework, Version 4.0.30319.1]
Copyright (C) Microsoft Corporation. All rights reserved.
Schema validation warning: Type 'http://www.zillow.com/static/xsd/ZillowTypes.xsd:Message' is not declared. Line 25, position 6.
Schema validation warning: Type 'http://www.zillow.com/static/xsd/ZillowTypes.xsd:SimpleProperty' is not declared. Line 33, position 12.

Warning: Schema could not be validated. Class generation may fail or may produce
 incorrect results.

Error: Error generating classes for schema 'SearchResults'.
  - The datatype 'http://www.zillow.com/static/xsd/ZillowTypes.xsd:Message' is missing.

It looks like everything is defined in the ZillowTypes.xsd so I am stumped.

like image 788
Denis Avatar asked Jan 19 '26 20:01

Denis


1 Answers

There are a couple of problems with the setup. Starting from the location of the XSD file, which is supposed to be at http://www.zillow.com/static/xsd/SearchResults.xsd

The above XSD is referencing another xsd using an import with a relative uri /vstatic/4/static/xsd/ZillowTypes.xsd which resolves to http://www.zillow.com/vstatic/4/static/xsd/ZillowTypes.xsd - but this URL is not dereferenceable (404)!!

If instead you try http://www.zillow.com/static/xsd/ZillowTypes.xsd then you found part 2 of your puzzle, which is ZillowTypes.xsd.

Because of these errors, you need to download both XSD files to your local machine to fix them.

Download first as SearchResults.xsd and second as ZillowTypes.xsd; put them in the same folder.

Edit SearchResults.xsd by changing the line below:

<xsd:import namespace="http://www.zillow.com/static/xsd/ZillowTypes.xsd" schemaLocation="/vstatic/4/static/xsd/ZillowTypes.xsd" /> 

to:

<xsd:import namespace="http://www.zillow.com/static/xsd/ZillowTypes.xsd" schemaLocation="ZillowTypes.xsd"  />

Then you run into another problem. ZillowTypes.xsd contains an invalid element declaration! So edit the decl below:

<xsd:complexType name="investmentBuyingBlock">
    <xsd:sequence>
        <xsd:element name="buying" minOccurs="0" maxOccurs="unbounded">
            <xsd:sequence>
                <xsd:element name="year" type="xsd:integer"/>
                <xsd:element name="rentalIncome" type="xsd:integer"/>
                <xsd:element name="otherIncome" type="xsd:integer"/>
                <xsd:element name="mortgagePayment" type="xsd:integer"/>
                <xsd:element name="principal" type="xsd:integer"/>
                <xsd:element name="interest" type="xsd:integer"/>
                <xsd:element name="hoaFees" type="xsd:integer"/>
                <xsd:element name="propertyTaxes" type="xsd:integer"/>
                <xsd:element name="utilities" type="xsd:integer"/>
                <xsd:element name="renovations" type="xsd:integer"/>
                <xsd:element name="maintainCosts" type="xsd:integer"/>
                <xsd:element name="homeOwnerInsurance" type="xsd:integer"/>
                <xsd:element name="managementFees" type="xsd:integer"/>
                <xsd:element name="advertisingCosts" type="xsd:integer"/>
                <xsd:element name="otherExpenses" type="xsd:integer"/>
                <xsd:element name="totalExpenses" type="xsd:integer"/>
                <xsd:element name="opportunityCostInitial" type="xsd:integer"/>
                <xsd:element name="opportunityCostYearly" type="xsd:integer"/>
                <xsd:element name="depreciationBuilding" type="xsd:integer"/>
                <xsd:element name="depreciationrenovation" type="xsd:integer"/>
                <xsd:element name="totalBenefit" type="xsd:integer"/>
                <xsd:element name="totalProfitLoss" type="xsd:integer"/>
            </xsd:sequence>
        </xsd:element>
    </xsd:sequence>
</xsd:complexType>

To:

<xsd:complexType name="investmentBuyingBlock">
    <xsd:sequence>
        <xsd:element name="buying" minOccurs="0" maxOccurs="unbounded">
            <xsd:complexType>
                <xsd:sequence>
                    <xsd:element name="year" type="xsd:integer"/>
                    <xsd:element name="rentalIncome" type="xsd:integer"/>
                    <xsd:element name="otherIncome" type="xsd:integer"/>
                    <xsd:element name="mortgagePayment" type="xsd:integer"/>
                    <xsd:element name="principal" type="xsd:integer"/>
                    <xsd:element name="interest" type="xsd:integer"/>
                    <xsd:element name="hoaFees" type="xsd:integer"/>
                    <xsd:element name="propertyTaxes" type="xsd:integer"/>
                    <xsd:element name="utilities" type="xsd:integer"/>
                    <xsd:element name="renovations" type="xsd:integer"/>
                    <xsd:element name="maintainCosts" type="xsd:integer"/>
                    <xsd:element name="homeOwnerInsurance" type="xsd:integer"/>
                    <xsd:element name="managementFees" type="xsd:integer"/>
                    <xsd:element name="advertisingCosts" type="xsd:integer"/>
                    <xsd:element name="otherExpenses" type="xsd:integer"/>
                    <xsd:element name="totalExpenses" type="xsd:integer"/>
                    <xsd:element name="opportunityCostInitial" type="xsd:integer"/>
                    <xsd:element name="opportunityCostYearly" type="xsd:integer"/>
                    <xsd:element name="depreciationBuilding" type="xsd:integer"/>
                    <xsd:element name="depreciationrenovation" type="xsd:integer"/>
                    <xsd:element name="totalBenefit" type="xsd:integer"/>
                    <xsd:element name="totalProfitLoss" type="xsd:integer"/>
                </xsd:sequence>
            </xsd:complexType>
        </xsd:element>
    </xsd:sequence>
</xsd:complexType>

The re-run you XSD command line by replacing

SearchResults.xml

with

SearchResults.xsd ZillowTypes.xsd

It should work (at least the XSDs are valid now).

like image 189
Petru Gardea Avatar answered Jan 22 '26 08:01

Petru Gardea