[AccessD] Opening an XML recordset

MartyConnelly martyconnelly at shaw.ca
Thu Aug 18 22:57:14 CDT 2005


The XML parses okay but you are trying to bring in a flat xml file with 
a self-contained xsd file
The ado call is expecting an ADTG formatted xml (MS special xml format 
definition for an ado recordset)  
As Charlotte said. You are going to have to parse each element out to a 
recordset field via the DOM.
Not a pleasant task. Generally when I use SOAP from a web service I 
parse out the relevant field strings
via XPATH from the DOM, if am I getting a limited amount of data say 
less than 1 K..
This is a lot easier to do with SQLXML

You could apply this xslt transform to remove all the ADTG junk to 
create a flat xml.
but that is not what you need.
ADOGeneric.xsl
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:z="#RowsetSchema">
    <s:Schema id="RowsetSchema"/>
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:template match="/">
    <xsl:apply-templates select="//z:row"/>
</xsl:template>

<xsl:template match="z:row">
    <xsl:text disable-output-escaping="yes"><row></xsl:text>
        <xsl:for-each select="@*">
            <xsl:text disable-output-escaping="yes"><</xsl:text>
            <xsl:value-of select="name()"/>
            <xsl:text disable-output-escaping="yes">></xsl:text>
            <xsl:value-of select="."/>
            <xsl:text disable-output-escaping="yes"></</xsl:text>
            <xsl:value-of select="name()"/>
            <xsl:text disable-output-escaping="yes">></xsl:text>
        </xsl:for-each>
    <xsl:text disable-output-escaping="yes"></row></xsl:text>
</xsl:template>
</xsl:stylesheet>


Francisco Tapia wrote:

>I have an XML document that I obtain from a webservice, I was able to creat 
>the schema and using XMLPad I can see that it is infact a valid document, 
>(see below). However the error Message I get from Access (2000) is that 
>"Recordset cannot be created. Source XML is incomplete or invalid."
>
>How can I make the following document a valid xml document for opening as an 
>ado recordset, ie:
>rst.Open "C:\ShipVia.xml", "Provider=MSPersist;", adOpenDynamic, 
>adLockReadOnly, adCmdFile
>
>
>thanks,
>
>I abbreviated the doc for simplyfing the post.
>
><?xml version="1.0" encoding="UTF-8"?>
><root xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
>xmlns:od="urn:schemas-microsoft-com:officedata">
><xsd:schema>
><xsd:element name="ArrayOfWSShipViaItem">
><xsd:complexType>
><xsd:sequence>
><xsd:element ref="WSShipViaItem" minOccurs="0" maxOccurs="unbounded"/>
></xsd:sequence>
><xsd:attribute name="generated" type="xsd:dateTime"/>
></xsd:complexType>
></xsd:element>
><xsd:element name="WSShipViaItem">
><xsd:annotation>
><xsd:appinfo/>
></xsd:annotation>
><xsd:complexType>
><xsd:sequence>
><xsd:element name="ID" minOccurs="0" od:jetType="text" 
>od:sqlSType="nvarchar">
><xsd:simpleType>
><xsd:restriction base="xsd:string">
><xsd:maxLength value="255"/>
></xsd:restriction>
></xsd:simpleType>
></xsd:element>
><xsd:element name="Description" minOccurs="0" od:jetType="text" 
>od:sqlSType="nvarchar">
><xsd:simpleType>
><xsd:restriction base="xsd:string">
><xsd:maxLength value="255"/>
></xsd:restriction>
></xsd:simpleType>
></xsd:element>
></xsd:sequence>
></xsd:complexType>
></xsd:element>
></xsd:schema>
><ArrayOfWSShipViaItem xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="
>http://HAASService.org//WSAvanteData">
><WSShipViaItem>
><ID>10</ID>
><Description>FED EX P1176208147 (SKINNER)</Description>
></WSShipViaItem>
></ArrayOfWSShipViaItem>
></root>
>
>
>  
>

-- 
Marty Connelly
Victoria, B.C.
Canada






More information about the AccessD mailing list