(re-posted from microsoft.public.xml)

Hi, I'm working on an XSD file to export some info for Google Base, but
I'm having an issue with "XPath: unable to find %1 in the schema".


When I remove the "targetSchema" and "xml:tns=xyz" lines (as well as
the tns prefix on the declarations), the schema
exports data with no problem.

Am I completely misunderstanding scoping for XML?

Below is my XSD, then the vbScript file I'm using:

<!---------------------------------
XSD------------------------------------>

<?xml version="1.0"?>



<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
xmlns:tns="http://base.google.com/ns/1.0"
targetNamespace="http://base.google.com/ns/1.0"
elementFormDefault="unqualified"
attributeFormDefault="unqualified">

<xsd:element name="listing" sql:relation="vw_listings"
sql:key-fields="listing_id">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="listing_id" sql:field="listing_id"
type="xsd:string"/>
<xsd:element name="property_type"
sql:field="property_type" type="xsd:string"/>
<xsd:element name="status" sql:field="status"
type="xsd:string"/>
<xsd:element name="currency" type="xsd:string"/>
<xsd:element name="price" type="xsd:string"/>

<xsd:element name="location_struct"
sql:relation="vw_listings" type="tns:locationStructType">
<xsd:annotation>
<xsd:appinfo>
<sql:relationship parent="vw_listings"
parent-key="listing_id" child="vw_listings" child-key="listing_id"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="unit" sql:relation="vw_listings"
type="tns:unitType">
<xsd:annotation>
<xsd:appinfo>
<sql:relationship parent="vw_listings"
parent-key="listing_id" child="vw_listings" child-key="listing_id"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>


<xsd:complexType name="locationStructType" >
<xsd:annotation>
<xsd:documentation>
Description of property location.
</xsd:documentation>
</xsd:annotation>
<xsd:all>
<xsd:element name="addr1" type="xsd:string" sql:field="addr1">
<xsd:annotation>
<xsd:documentation>
The first line of a street address. E.g. "100A N. Main
St. SW".
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="city" type="xsd:string" sql:field="city">
<xsd:annotation>
<xsd:documentation>
City name. E.g. Brooklyn.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="province" type="xsd:string"
sql:field="province">
<xsd:annotation>
<xsd:documentation>
Province/state name or abbreviation. E.g. NY.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="postal_code" type="xsd:string"
sql:field="postal_code">
<xsd:annotation>
<xsd:documentation>
Postal code. E.g. 11215.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="country" type="xsd:string" sql:field="country">
<xsd:annotation>
<xsd:documentation>
Country code according to the ISO 3166-1-alpha-2
standard.

http://www.iso.org/iso/en/prods-serv.../list-en1.html.
E.g. US for United States.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="county" type="xsd:string" minOccurs="0"
sql:mapped="0">
<xsd:annotation>
<xsd:documentation>
County.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
</xsd:all>
</xsd:complexType>


<xsd:complexType name="unitType">
<xsd:annotation>
<xsd:documentation>
Description of residence.
</xsd:documentation>
</xsd:annotation>
<xsd:all>

<xsd:element name="bedrooms" sql:field="bedrooms">
<xsd:annotation>
<xsd:documentation>
Number of bedrooms. E.g. 3.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="bathrooms" sql:field="bathrooms">
<xsd:annotation>
<xsd:documentation>
Total number of bathrooms (full and three-quarter and
half).
E.g. 2.5 means there are two full bathrooms and one half
bathroom.
</xsd:documentation>
</xsd:annotation>
</xsd:element>


</xsd:all>
</xsd:complexType>


</xsd:schema>


<!--------------------------------- VEE BEE ESS
------------------------------------>



Const adCmdText = 1
Const adExecuteStream = 1024

Public Function XPathQuery()

Dim adoConn 'As New ADODB.Connection
Dim adoCmd 'As New ADODB.Command
Dim adoStream 'As New ADODB.Stream
Dim xmlDoc


Set adoConn = CreateObject("ADODB.Connection")
Set adoCmd = CreateObject("ADODB.Command")
Set adoStream = CreateObject("ADODB.Stream")
Set xmlDoc= CreateObject("MSXML.DOMDocument")


adoConn.Open "Provider=SQLXMLOLEDB;Data
Provider=SQLOLEDB;Server=SQLSERVER;Database=DBNAME;Integrated
Security='SSPI';"

Set adoCmd.ActiveConnection = adoConn
adoCmd.CommandType = adCmdText
adoCmd.Dialect = "{EC2A4293-E898-11D2-B1B7-00C04F680C56}"
adoCmd.Properties("Mapping Schema") = "test.xsd"

adoCmd.Properties("xml root") = "listing"
adoCmd.Properties("Output Stream") = xmlDoc
adoCmd.CommandText = "/listing"

adoCmd.Execute , , adExecuteStream

wscript.echo "Creating results.xml..."
xmlDoc.Save "results.xml"
wscript.echo "results.xml created."

End Function


XPathQuery()