CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    May 1999
    Location
    Saint Paul, Minnesota, US
    Posts
    91

    Trouble using sql:relation/sql:relationship in xsd file ...

    Trouble using sql:relation/sql:relationship in xsd file ...


    Hi ...

    I am attempting to use the sql:relation annotation and am having some troubles. I have used it successfull with the MS Sample (Customer / Order) where all the data is contained in elements (example below).

    Code:
    <ROOT>
      <Customers>
        <CustomerID>1111</CustomerID>
        <SynchID>700</SynchID>
        <CompanyName>Sean Chai</CompanyName>
        <City>NY</City>
        <Order OrderID="1" />
        <Order OrderID="2" />
      </Customers>
    </ROOT>
    
    In the xml that I am having trouble with the data is contained in attributes.  In the code below I get the following 
    error when executing the bulk insert. 
    
    Any comments ? 
    Thanks !! 
    Chris 
    
    
    
    //////////////////////////////////////////////////////////////////////////
    // error message 
    <?xml version="1.0"?><Result State="FAILED"><Error><HResult>0x80004005</HResult><Description><![CDATA[Schema: the parent/child table of the relationship on 'surface' does not match.]]></Description><Source>Schema mapping</Source><Type>FATAL</Type></Error></Result>
    
    
    //////////////////////////////////////////////////////////////////////////
    // xsd file 
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
                
      <xsd:annotation>
        <xsd:appinfo>
          <sql:relationship name="MacgowanTest_Atmospheric_Surface"
                parent="MacgowanTestRWISRawAtmospheric"
                parent-key="SystemId RpuId"
                child="MacgowanTestRWISRawSurface"
                child-key="SystemId RpuId" />
        </xsd:appinfo>
      </xsd:annotation>
                
      <xsd:element name="site" sql:relation="MacgowanTestRWISRawAtmospheric" >
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="sensors" sql:relation="MacgowanTestRWISRawSurface" 
                                        sql:relationship="MacgowanTest_Atmospheric_Surface">
              <xsd:complexType>
                <xsd:sequence>
                  <xsd:element name="surface" sql:relation="MacgowanTestRWISRawSurface"
                                              sql:relationship="MacgowanTest_Atmospheric_Surface" >
                    <xsd:complexType>
                      <xsd:attribute name="id" type="xsd:string" sql:field="SensorId"/>
                      <xsd:attribute name="datetime" type="xsd:date" sql:field="ObsDateTime" />
                      <xsd:attribute name="surfacecondition" type="xsd:string" sql:field="SurfaceCondition"/>
                      <xsd:attribute name="surfacetemp" type="xsd:string" sql:field="SurfaceTemperature"/>
                    </xsd:complexType>
                  </xsd:element>
                </xsd:sequence>
              </xsd:complexType>
            </xsd:element>
          </xsd:sequence>
        
          <xsd:attribute name="sysid" type="xsd:string" sql:field="SystemId"/>
          <xsd:attribute name="rpuid" type="xsd:string" sql:field="RpuId"/>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>
    
    
    
    //////////////////////////////////////////////////////////////////////////
    // xml data file 
    <?xml version="1.0"?>
    <odot_rwis_site_info>
      <site id="200000" number="1" sysid="200" rpuid="0" name="1-SR127 @ SR249" longitude="-84.554946" latitude="41.383527">
        <atmospheric datetime="12/05/2005 03:48:00 PM" airtemp="-490" dewpoint="-800" relativehumidity="73" windspeedavg="11" windspeedgust="19" winddirectionavg="265" winddirectiongust="295" pressure="65535" precipitationintensity="None" precipitationtype="None" precipitationrate="0" precipitationaccumulation="-1" visibility="2000" />
        <sensors>
          <surface id="0" datetime="12/05/2005 03:48:00 PM" name="North Bound Driving Lane" surfacecondition="Dry" surfacetemp="1900" freezingtemp="32767" chemicalfactor="255" chemicalpercent="255" depth="32767" icepercent="255" subsurfacetemp="450" waterlevel="0">
            <traffic datetime="12/05/2005 03:48:00 PM" occupancy="0" avgspeed="82" volume="21" sftemp="1900" sfstate="255">
              <normalbins>
                <bin datetime="12/05/2005 03:48:00 PM" binnumber="0" bincount="7" />
                <bin datetime="12/05/2005 03:48:00 PM" binnumber="1" bincount="0" />
              </normalbins>
              <longbins>
                <bin datetime="12/05/2005 03:48:00 PM" binnumber="2" bincount="0" />
                <bin datetime="12/05/2005 03:48:00 PM" binnumber="3" bincount="0" />
                <bin datetime="12/05/2005 03:48:00 PM" binnumber="4" bincount="1" />
                <bin datetime="12/05/2005 03:48:00 PM" binnumber="5" bincount="0" />
              </longbins>
            </traffic>
          </surface>
          <surface id="1" datetime="12/05/2005 03:48:00 PM" name="Bridge Deck Simulator" surfacecondition="Other" surfacetemp="-60" freezingtemp="32767" chemicalfactor="255" chemicalpercent="255" depth="32767" icepercent="255" subsurfacetemp="-999999" waterlevel="0" />
        </sensors>
      </site>
      <site id="200001" number="2" sysid="200" rpuid="1" name="2-Hardin County Garage" longitude="-83.6148588" latitude="40.6305358">
        <atmospheric datetime="12/05/2005 03:49:00 PM" airtemp="-590" dewpoint="-900" relativehumidity="75" windspeedavg="9" windspeedgust="22" winddirectionavg="303" winddirectiongust="299" pressure="65535" precipitationintensity="None" precipitationtype="None" precipitationrate="0" precipitationaccumulation="-1" visibility="2000" />
        <sensors>
          <surface id="0" datetime="12/05/2005 03:49:00 PM" name="Bridge Deck Simulator" surfacecondition="Other" surfacetemp="-410" freezingtemp="32767" chemicalfactor="255" chemicalpercent="255" depth="32767" icepercent="255" subsurfacetemp="300" waterlevel="0" />
        </sensors>
      </site>
      </odot_rwis_site_info>

  2. #2
    Join Date
    May 1999
    Location
    Saint Paul, Minnesota, US
    Posts
    91

    Re: Trouble using sql:relation/sql:relationship in xsd file ...

    Hi ...

    I have added the self-join relationship (MacgowanTest_Surface_Surface) and the data is now being bulk loaded into both tables. Below is the schema file.

    Thanks,
    Chris

    Code:
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
               
      <xsd:annotation>
        <xsd:appinfo>
          <sql:relationship name="MacgowanTest_Atmospheric_Surface"
                parent="MacgowanTestRWISRawAtmospheric"
                parent-key="SystemId RpuId"
                child="MacgowanTestRWISRawSurface"
                child-key="SystemId RpuId" />
        </xsd:appinfo>
      </xsd:annotation>
     
      <xsd:annotation>
        <xsd:appinfo>
          <sql:relationship name="MacgowanTest_Surface_Surface"
                parent="MacgowanTestRWISRawSurface"
                parent-key="SystemId RpuId"
                child="MacgowanTestRWISRawSurface"
                child-key="SystemId RpuId" />
        </xsd:appinfo>
      </xsd:annotation>
               
      <xsd:element name="site" sql:relation="MacgowanTestRWISRawAtmospheric" >
        <xsd:complexType>
          <xsd:sequence>
            <xsd:element name="sensors" sql:relation="MacgowanTestRWISRawSurface"
                                        sql:relationship="MacgowanTest_Atmospheric_Surface">
              <xsd:complexType>
                <xsd:sequence>
                  <xsd:element name="surface" sql:relation="MacgowanTestRWISRawSurface"
                                              sql:relationship="MacgowanTest_Surface_Surface" >
                    <xsd:complexType>
                      <xsd:attribute name="id" type="xsd:string" sql:field="SensorId"/>
                      <xsd:attribute name="datetime" type="xsd:date" sql:field="ObsDateTime" />
                      <xsd:attribute name="surfacecondition" type="xsd:string" sql:field="SurfaceCondition"/>
                      <xsd:attribute name="surfacetemp" type="xsd:string" sql:field="SurfaceTemperature"/>
                    </xsd:complexType>
                  </xsd:element>
                </xsd:sequence>
              </xsd:complexType>
            </xsd:element>
          </xsd:sequence>
       
          <xsd:attribute name="sysid" type="xsd:string" sql:field="SystemId"/>
          <xsd:attribute name="rpuid" type="xsd:string" sql:field="RpuId"/>
        </xsd:complexType>
      </xsd:element>
    </xsd:schema>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured