Добро пожаловать в форум, Guest  >>   Войти | Регистрация | Поиск | Правила | В избранное | Подписаться
Все форумы / Microsoft SQL Server Новый топик    Ответить
 sqlXmlBulkLoad: тайна, которая меня мучает  [new]
aleks2
Guest
Ну не получается у мя написать схему

Файл XML, который грузится нормально
+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body SOAP-ENC:encodingStyle="http://schemas.xmlsoap.org/soap/envelope/">
<NS1:GetHotelDetailListResponse xmlns:NS1="urn:webservice-electrasoft-ru:types-twsReservationServiceIntf-ItwsReservationService">
<return xsi:type="xsd:string">
<HotelList>
<Hotel HotelShortName="Яш-Тан (Абзаково)" >
</Hotel>
</HotelList>
</return>
</NS1:GetHotelDetailListResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>



Схема Schema.xsd
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
            xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
            xmlns:NS1="urn:webservice-electrasoft-ru:types-twsReservationServiceIntf-ItwsReservationService"
            xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
            targetNamespace="http://schemas.xmlsoap.org/soap/envelope/"
            elementFormDefault="qualified"
>
<xsd:import schemaLocation="Schema2.xsd" namespace="urn:webservice-electrasoft-ru:types-twsReservationServiceIntf-ItwsReservationService" />

  <xsd:annotation>
   <xsd:appinfo>
    <sql:relationship name="BHD"
          parent="[body]"
          parent-key="bodyID"
          child="[descrs]"
          child-key="bodyID" />
   </xsd:appinfo>
  </xsd:annotation>

  <xsd:element name="Envelope" sql:is-constant="1">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="Body" minOccurs="1" maxOccurs="1" 
                   sql:relation="[body]" 
                   sql:key-fields="dummy bodyID"
                   sql:overflow-field="OverflowColumn"
        >
          <xsd:complexType>
            <xsd:sequence>
              <xsd:element ref="NS1:GetHotelDetailListResponse" minOccurs="0" maxOccurs="1"/>
            </xsd:sequence>

            <xsd:attribute name="bodyID" type="xsd:int" default="-1" />
            <xsd:attribute name="dummy"  type="xsd:int" default="0" />
   
          </xsd:complexType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>


Схема Schema2.xsd
+
    <xsd:schema xmlns="urn:webservice-electrasoft-ru:types-twsReservationServiceIntf-ItwsReservationService" 
               xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
               targetNamespace="urn:webservice-electrasoft-ru:types-twsReservationServiceIntf-ItwsReservationService"
               elementFormDefault="unqualified"
    >
              <xsd:element name="GetHotelDetailListResponse" sql:is-constant="1">
                <xsd:complexType>
                  <xsd:sequence>
                     <xsd:element name="return" sql:is-constant="1" minOccurs="0" maxOccurs="1">
                      <xsd:complexType>
                        <xsd:sequence>
                          <xsd:element name="HotelList" sql:is-constant="1" minOccurs="0" maxOccurs="1">
                           <xsd:complexType>
                            <xsd:sequence>
                               <xsd:element name="Hotel" minOccurs="0" maxOccurs="unbounded" 
                                      sql:relation="[descrs]" 
                                      sql:key-fields="hotelID"
                                      sql:relationship="BHD"
                                      sql:overflow-field="OverflowColumn"
                               >
                                <xsd:complexType>
                                   <xsd:attribute name="bodyID"         type="xsd:int"    default="-1" />
                                   <xsd:attribute name="HotelShortName" type="xsd:string" sql:datatype="nvarchar(24)" sql:field="hotelID" use="required" />
                                </xsd:complexType>
                               </xsd:element>
                            </xsd:sequence>
                           </xsd:complexType>
                          </xsd:element>
                        </xsd:sequence>
                      </xsd:complexType>
                     </xsd:element>
                  </xsd:sequence>
                </xsd:complexType>
              </xsd:element>
    </xsd:schema>


Файл XML, который НЕ грузится
+
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body SOAP-ENC:encodingStyle="http://schemas.xmlsoap.org/soap/envelope/">
<NS1:GetHotelDetailListResponse xmlns:NS1="urn:webservice-electrasoft-ru:types-twsReservationServiceIntf-ItwsReservationService">
<return xsi:type="xsd:string">
<HotelList xmlns="urn:schemas-som-ru:tws-reservationHotelDetailList">
<Hotel HotelShortName="Яш-Тан (Абзаково)" >
</Hotel>
</HotelList>
</return>
</NS1:GetHotelDetailListResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Всей разницы
<HotelList>
и
<HotelList xmlns="urn:schemas-som-ru:tws-reservationHotelDetailList">

И как не пытался я его уломать - не выходит каменный цветок.

Загружалка
+
Dim objBL 
Set objBL = CreateObject("SQLXMLBulkLoad.SQLXMLBulkload.4.0")
objBL.ConnectionString = "provider=SQLOLEDB;data source=.\moretravel;database=tempdb;integrated security=SSPI"
objBL.ErrorLogFile = "error.log"

objBL.SchemaGen = True
objBL.SGDropTables = TRUe

objBL.Execute "Schema.xsd", "data0.xml "
Set objBL = Nothing


Призываются владеющие эзотерическим знанием!
3 мар 16, 20:26    [18894058]     Ответить | Цитировать Сообщить модератору
 Re: sqlXmlBulkLoad: тайна, которая меня мучает  [new]
andrey odegov
Member

Откуда:
Сообщений: 473
xml
+
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
  <SOAP-ENV:Body
    SOAP-ENC:encodingStyle="http://schemas.xmlsoap.org/soap/envelope/">
    <NS1:GetHotelDetailListResponse
      xmlns:NS1="urn:webservice-electrasoft-ru:types-twsReservationServiceIntf-ItwsReservationService">
      <return xsi:type="xsd:string">
        <HotelList xmlns="urn:schemas-som-ru:tws-reservationHotelDetailList">
          <Hotel HotelShortName="Яш-Тан (Абзаково)"/>
        </HotelList>
      </return>
    </NS1:GetHotelDetailListResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
schema.xsd
+
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema
  xmlns="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
  xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
  xmlns:NS1="urn:webservice-electrasoft-ru:types-twsReservationServiceIntf-ItwsReservationService">
  <xsd:import schemaLocation="schema2.xsd"
    namespace="urn:webservice-electrasoft-ru:types-twsReservationServiceIntf-ItwsReservationService"/>
  <xsd:element name="Envelope" sql:is-constant="1">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="Body" sql:is-constant="1">
          <xsd:complexType>
            <xsd:sequence>
              <xsd:element ref="NS1:GetHotelDetailListResponse"/>
            </xsd:sequence>
            <xsd:anyAttribute processContents="skip"/>
          </xsd:complexType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>
schema2.xsd
+
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema
  xmlns="urn:webservice-electrasoft-ru:types-twsReservationServiceIntf-ItwsReservationService"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
  xmlns:hl="urn:schemas-som-ru:tws-reservationHotelDetailList"
  targetNamespace="urn:webservice-electrasoft-ru:types-twsReservationServiceIntf-ItwsReservationService">
  <xsd:import schemaLocation="schema3.xsd"
    namespace="urn:schemas-som-ru:tws-reservationHotelDetailList"/>
  <xsd:element name="GetHotelDetailListResponse" sql:is-constant="1">
    <xsd:complexType>
      <xsd:sequence>
        <xsd:element name="return" form="unqualified" sql:is-constant="1">
          <xsd:complexType>
            <xsd:sequence>
              <xsd:element name="HotelList" form="unqualified" sql:is-constant="1">
                <xsd:complexType>
                  <xsd:sequence>
                    <xsd:element ref="hl:Hotel"/>
                  </xsd:sequence>
                </xsd:complexType>
              </xsd:element>
            </xsd:sequence>
          </xsd:complexType>
        </xsd:element>
      </xsd:sequence>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>
schema3.xsd
+
<?xml version="1.0" encoding="utf-8"?>
<xsd:schema
  xmlns="urn:schemas-som-ru:tws-reservationHotelDetailList"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
  targetNamespace="urn:schemas-som-ru:tws-reservationHotelDetailList"
  elementFormDefault="unqualified">
  <xsd:element name="Hotel"
    sql:relation="[descrs]"
    sql:key-fields="hotelID">
    <xsd:complexType>
      <xsd:attribute name="HotelShortName" type="xsd:string"
        sql:field="hotelID" sql:datatype="nvarchar(30)"/>
    </xsd:complexType>
  </xsd:element>
</xsd:schema>
schema.ps1
+
cls
$erroractionpreference='stop'
$path=split-path $myinvocation.mycommand.path
$sxbl=new-object -com sqlxmlbulkload.sqlxmlbulkload.4.0
$sxbl.connectionstring=@'
provider=sqlncli11;
data source=lpc:.\mss2014xe;
initial catalog=tempdb;
integrated security=sspi
'@
$sxbl.checkconstraints=$true
$sxbl.errorlogfile=join-path $path error.xml
$sxbl.keepidentity=$true
$sxbl.schemagen=$true
$sxbl.sgdroptables=$true
$fxs=join-path $path hotel.xsd
$fxm=join-path $path hotel.xml
$sxbl.execute($fxs,$fxm)
write-host done
4 мар 16, 03:11    [18894863]     Ответить | Цитировать Сообщить модератору
 Re: sqlXmlBulkLoad: тайна, которая меня мучает  [new]
aleks2
Guest
А! Вон оно что!
А я то эту шнягу
<xsd:element name="HotelList" form="unqualified" sql:is-constant="1"
пихал в Schema3.xsd.
4 мар 16, 06:02    [18894915]     Ответить | Цитировать Сообщить модератору
 Re: sqlXmlBulkLoad: тайна, которая меня мучает  [new]
aleks2
Guest
Мистика, все равно, сохранилась.

Переделал я схему, согласно заветам (я здесь оставил полную версию)
Схема Schema.xsd ()
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
            xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
            xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
            xmlns:NS1="urn:webservice-electrasoft-ru:types-twsReservationServiceIntf-ItwsReservationService"
            xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
            targetNamespace="http://schemas.xmlsoap.org/soap/envelope/"
            elementFormDefault="qualified"
>
<xsd:import schemaLocation="ItwsReservationService2.xsd" namespace="urn:webservice-electrasoft-ru:types-twsReservationServiceIntf-ItwsReservationService" />

  <xsd:annotation>
   <xsd:appinfo>

    <sql:relationship name="BHL"
          parent="[alean_body]"
          parent-key="bodyID"
          child="[alean_hotels]"
          child-key="bodyID" />

    <sql:relationship name="BF"
          parent="[alean_body]"
          parent-key="bodyID"
          child="[alean_fault]"
          child-key="bodyID" />

    <sql:relationship name="BHD"
          parent="[alean_body]"
          parent-key="bodyID"
          child="[alean_descrs]"
          child-key="bodyID" />

    <sql:relationship name="DT"
          parent="[alean_descrs]"
          parent-key="bodyID hotelID"
          child="[alean_descr_Tours]"
          child-key="bodyID hotelID" />

    <sql:relationship name="DHG"
          parent="[alean_descrs]"
          parent-key="bodyID hotelID"
          child="[alean_descr_HotelGroups]"
          child-key="bodyID hotelID" />

    <sql:relationship name="DRC"
          parent="[alean_descrs]"
          parent-key="bodyID hotelID"
          child="[alean_descr_RoomCategories]"
          child-key="bodyID hotelID" />
   </xsd:appinfo>
  </xsd:annotation>

  <xsd:element name="Envelope" sql:is-constant="1">
    <xsd:complexType>
      <xsd:sequence>

        <xsd:element name="Body" minOccurs="1" maxOccurs="1" 
                   sql:relation="[alean_body]" 
                   sql:key-fields="dummy bodyID"
                   sql:overflow-field="OverflowColumn"
        >
          <xsd:complexType>
            <xsd:sequence>

              <xsd:element ref="NS1:GetAvailableHotelListResponse" minOccurs="0" maxOccurs="1"/>

              <xsd:element ref="NS1:GetHotelDetailListResponse" minOccurs="0" maxOccurs="1"/>

              <xsd:element name="Fault" minOccurs="0" maxOccurs="1"
                          sql:relation="[alean_fault]"
                          sql:key-fields="faultID"
                          sql:relationship="BF"
                          sql:overflow-field="OverflowColumn"
              >
                <xsd:complexType>
                  <xsd:sequence>
                    <xsd:element name="faultcode"   form="unqualified" type="xsd:string" sql:datatype="nvarchar(256)"/>
                    <xsd:element name="faultstring" form="unqualified" type="xsd:string" sql:datatype="nvarchar(256)"/>
                    <xsd:element name="faultactor"  form="unqualified" type="xsd:string" sql:datatype="nvarchar(256)"/>
                  </xsd:sequence>

                  <xsd:attribute name="bodyID" type="xsd:int" default="-1" />
                  <xsd:attribute name="faultID" type="xsd:int" default="-1" />

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

            </xsd:sequence>

            <xsd:attribute name="bodyID" type="xsd:int" default="-1" />
            <xsd:attribute name="dummy"  type="xsd:int" default="0" />
            <xsd:anyAttribute processContents="skip"/>
   
          </xsd:complexType>
        </xsd:element>

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

</xsd:schema>


Схема ItwsReservationService2.xsd
+
    <xsd:schema xmlns="urn:webservice-electrasoft-ru:types-twsReservationServiceIntf-ItwsReservationService" 
               xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
               xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
               xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
               xmlns:hl="urn:schemas-som-ru:tws-reservationHotelDetailList"

               targetNamespace="urn:webservice-electrasoft-ru:types-twsReservationServiceIntf-ItwsReservationService"
               elementFormDefault="unqualified"
    >

    <xsd:import schemaLocation="Hotel.xsd" namespace="urn:schemas-som-ru:tws-reservationHotelDetailList" />

              <xsd:element name="GetAvailableHotelListResponse" sql:is-constant="1">
                <xsd:complexType>
                  <xsd:sequence>

                     <xsd:element name="return" sql:is-constant="1" minOccurs="0" maxOccurs="1">
                      <xsd:complexType>
                        <xsd:sequence>

                         <xsd:element name="item" 
                                      sql:relation="[alean_hotels]" 
                                      sql:relationship="BHL"
                                      sql:key-fields="hotelID"
                                      sql:overflow-field="OverflowColumn"
                                      minOccurs="0" maxOccurs="unbounded" sql:datatype="nvarchar(24)" sql:field="hotelID"
                         >
                          <xsd:complexType>
                           <xsd:simpleContent>
                            <xsd:extension base="xsd:string" >
                              <xsd:attribute name="bodyID" type="xsd:int" default="-1" />
                            </xsd:extension>
                           </xsd:simpleContent>
                          </xsd:complexType>
                         </xsd:element>

                        </xsd:sequence>

                        <xsd:anyAttribute processContents="skip"/>

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


                  </xsd:sequence>

                  <xsd:anyAttribute processContents="skip"/>

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


              <xsd:element name="GetHotelDetailListResponse" sql:is-constant="1">
                <xsd:complexType>
                  <xsd:sequence>

                     <xsd:element name="return" form="unqualified" sql:is-constant="1" minOccurs="0" maxOccurs="1">
                      <xsd:complexType>
                        <xsd:sequence>

                          <xsd:element name="HotelList" form="unqualified" sql:is-constant="1" >
                           <xsd:complexType>
                            <xsd:sequence>

                              <xsd:element ref="hl:Hotel" minOccurs="0" maxOccurs="unbounded"/>

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

                        </xsd:sequence>

                        <xsd:anyAttribute processContents="skip"/>

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

                  </xsd:sequence>

                  <xsd:anyAttribute processContents="skip"/>

                </xsd:complexType>
              </xsd:element>
    </xsd:schema>


Схема Hotel.xsd
+
<xsd:schema    xmlns="urn:schemas-som-ru:tws-reservationHotelDetailList"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
               targetNamespace="urn:schemas-som-ru:tws-reservationHotelDetailList"
               elementFormDefault="unqualified"
>

<xsd:simpleType name="ShortNameType" sql:datatype="nvarchar(24)">
  <xsd:restriction base="xsd:string">
    <xsd:maxLength value="24"/>
  </xsd:restriction>
</xsd:simpleType>

<xsd:attributeGroup name="ids">
     <xsd:attribute name="bodyID"         type="xsd:int"       default="-1" />
     <xsd:attribute name="HotelShortName" type="ShortNameType" sql:datatype="nvarchar(24)" sql:field="hotelID" use="required" />
</xsd:attributeGroup>

<xsd:attributeGroup name="Status">
    <xsd:attribute name="AvailableStatus"    type="xsd:string" sql:datatype="varchar(256)" />
</xsd:attributeGroup>

                               <xsd:element name="Hotel" 
                                      sql:relation="[alean_descrs]" 
                                      sql:key-fields="hotelID"
                                      sql:relationship="BHD"
                                      sql:overflow-field="OverflowColumn"
                               >
                                <xsd:complexType>
                                  <xsd:sequence>

                                    <xsd:element name="TourList" sql:is-constant="1" minOccurs="0" maxOccurs="1" >
                                     <xsd:complexType>
                                      <xsd:sequence>

                                        <xsd:element name="Tour" minOccurs="0" maxOccurs="unbounded" 
                                                     sql:relation="[alean_descr_Tours]" 
                                                     sql:relationship="DT"
                                                     sql:key-fields="hotelID TourShortName"
                                                     sql:overflow-field="OverflowColumn"
                                        >
                                         <xsd:complexType>
                                            <xsd:attributeGroup ref="ids"/>
                                            <xsd:attribute name="TourShortName" type="ShortNameType" sql:datatype="nvarchar(24)" use="required"/>
                                            <xsd:attribute name="TourName"      type="xsd:string" sql:datatype="nvarchar(256)" />
                                            <xsd:attributeGroup ref="Status"/>
                                         </xsd:complexType>
                                        </xsd:element>

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


                                    <xsd:element name="HotelGroupList" sql:is-constant="1" minOccurs="0" maxOccurs="1" >
                                     <xsd:complexType>
                                      <xsd:sequence>

                                        <xsd:element name="HotelGroup" minOccurs="0" maxOccurs="unbounded" 
                                                     sql:relation="[alean_descr_HotelGroups]" 
                                                     sql:relationship="DHG"
                                                     sql:key-fields="hotelID HotelGroupShortName"
                                                     sql:overflow-field="OverflowColumn"
                                        >
                                         <xsd:complexType>
                                            <xsd:attributeGroup ref="ids"/>
                                            <xsd:attribute name="HotelGroupShortName" type="ShortNameType" sql:datatype="nvarchar(24)" use="required"/>
                                            <xsd:attribute name="HotelGroupName"      type="xsd:string" sql:datatype="nvarchar(256)" />
                                         </xsd:complexType>
                                        </xsd:element>

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

                                    <xsd:element name="RoomCategoryList" sql:is-constant="1" minOccurs="0" maxOccurs="1" >
                                     <xsd:complexType>
                                      <xsd:sequence>

                                        <xsd:element name="RoomCategory" minOccurs="0" maxOccurs="unbounded" 
                                                     sql:relation="[alean_descr_RoomCategories]" 
                                                     sql:relationship="DRC"
                                                     sql:key-fields="hotelID RoomTypeShortName RoomCategoryShortName"
                                                     sql:overflow-field="OverflowColumn"
                                        >
                                         <xsd:complexType>
                                            <xsd:attributeGroup ref="ids"/>
                                            <xsd:attribute name="RoomTypeShortName"     type="ShortNameType" sql:datatype="nvarchar(24)" use="required"/>
                                            <xsd:attribute name="RoomTypeName"          type="xsd:string"    sql:datatype="nvarchar(256)" />
                                            <xsd:attribute name="RoomCategoryShortName" type="ShortNameType" sql:datatype="nvarchar(24)" />
                                            <xsd:attribute name="RoomCategoryName"      type="xsd:string"    sql:datatype="nvarchar(256)" />
                                            <xsd:attribute name="BaseSeatQuantity"      type="xsd:int" />
                                            <xsd:attribute name="ExtSeatQuantity"       type="xsd:int" />
                                         </xsd:complexType>
                                        </xsd:element>

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

                                  </xsd:sequence>

                                 <xsd:attributeGroup ref="ids"/>
                                 <xsd:attribute name="HotelName"          type="xsd:string"    sql:datatype="nvarchar(256)" />
                                 <xsd:attribute name="HotelTypeShortName" type="ShortNameType" sql:datatype="nvarchar(24)" />
                                 <xsd:attribute name="HotelTypeName"      type="xsd:string"    sql:datatype="nvarchar(256)" />
                                 <xsd:attribute name="TownName"           type="xsd:string"    sql:datatype="nvarchar(256)" />
                                 <xsd:attribute name="AreaName"           type="xsd:string"    sql:datatype="nvarchar(256)" />
                                 <xsd:attribute name="RegionName"         type="xsd:string"    sql:datatype="nvarchar(256)" />
                                 <xsd:attribute name="CountryName"        type="xsd:string"    sql:datatype="nvarchar(256)" />
                                 <xsd:attributeGroup ref="Status"/>

                                </xsd:complexType>
                               </xsd:element>
</xsd:schema>


Данные
+
<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body SOAP-ENC:encodingStyle="http://schemas.xmlsoap.org/soap/envelope/">

<NS1:GetHotelDetailListResponse xmlns:NS1="urn:webservice-electrasoft-ru:types-twsReservationServiceIntf-ItwsReservationService">
<return xsi:type="xsd:string">
<HotelList xmlns="urn:schemas-som-ru:tws-reservationHotelDetailList">

<Hotel HotelShortName="Яш-Тан (Абзаково)" HotelName="Яш-Тан (Абзаково)" HotelTypeShortName="Гостиница" HotelTypeName="Гостиница" TownName="Абзаково" AreaName="Белорецкий район" RegionName="Башкортостан" CountryName="Россия" AvailableStatus="AVAILABLE">

  <TourList>
   <Tour TourShortName="Абзаково-Банное" TourName="Абзаково-Банное"/>
 </TourList>

 <HotelGroupList>
  <HotelGroup HotelGroupShortName="Абзаково" HotelGroupName="Абзаково"/>
 </HotelGroupList>

 <RoomCategoryList>
  <RoomCategory RoomTypeShortName="Полулюкс" RoomTypeName="Полулюкс" RoomCategoryShortName="2-местный " RoomCategoryName="2-местный" BaseSeatQuantity="2" ExtSeatQuantity="2"/>
 </RoomCategoryList>

</Hotel>

</HotelList>
</return>
</NS1:GetHotelDetailListResponse>

</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Я ужо было обрадовался . Ан нет. Схемы так просто не сдаются.
<Hotel - грузится.
А все вложенное - нифига
<TourList>
<HotelGroupList>
<RoomCategoryList>
4 мар 16, 07:41    [18894999]     Ответить | Цитировать Сообщить модератору
 Re: sqlXmlBulkLoad: тайна, которая меня мучает  [new]
aleks2
Guest
Да. Тайна XSD - велика есть.
Я ее поборол, но, убей бог, не понимаю в чем тут фишка?

Итак, переписанный Hotel.xsd
+
<xsd:schema    xmlns="urn:schemas-som-ru:tws-reservationHotelDetailList"
               xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
               xmlns:sql="urn:schemas-microsoft-com:mapping-schema"
               targetNamespace="urn:schemas-som-ru:tws-reservationHotelDetailList"
               elementFormDefault="unqualified"
>

<xsd:simpleType name="ShortNameType" >
  <xsd:restriction base="xsd:string">
    <xsd:maxLength value="24"/>
  </xsd:restriction>
</xsd:simpleType>

<xsd:attributeGroup name="ids">
     <xsd:attribute name="bodyID"         type="xsd:int"       default="-1" />
     <xsd:attribute name="HotelShortName" type="ShortNameType" sql:datatype="nvarchar(24)" sql:field="hotelID" use="required" />
</xsd:attributeGroup>

<xsd:attributeGroup name="Status">
    <xsd:attribute name="AvailableStatus"    type="xsd:string" sql:datatype="varchar(256)" />
</xsd:attributeGroup>

<xsd:element name="Tour" 
             sql:relation="[alean_descr_Tours]" 
             sql:relationship="DT"
             sql:key-fields="hotelID TourShortName"
             sql:overflow-field="OverflowColumn"
>
 <xsd:complexType>
   <xsd:attributeGroup ref="ids"/>
   <xsd:attribute name="TourShortName" type="ShortNameType" sql:datatype="nvarchar(24)" use="required"/>
   <xsd:attribute name="TourName"      type="xsd:string" sql:datatype="nvarchar(256)" />
   <xsd:attributeGroup ref="Status"/>
 </xsd:complexType>
</xsd:element>

<xsd:element name="TourList" sql:is-constant="1" >
  <xsd:complexType>
    <xsd:sequence>
       <xsd:element ref="Tour" minOccurs="0" maxOccurs="1" />
    </xsd:sequence>
  </xsd:complexType>
</xsd:element>

<xsd:element name="HotelGroup" 
             sql:relation="[alean_descr_HotelGroups]" 
             sql:relationship="DHG"
             sql:key-fields="hotelID HotelGroupShortName"
             sql:overflow-field="OverflowColumn"
>
  <xsd:complexType>
     <xsd:attributeGroup ref="ids"/>
     <xsd:attribute name="HotelGroupShortName" type="ShortNameType" sql:datatype="nvarchar(24)" use="required"/>
     <xsd:attribute name="HotelGroupName"      type="xsd:string" sql:datatype="nvarchar(256)" />
  </xsd:complexType>
</xsd:element>

<xsd:element name="HotelGroupList" sql:is-constant="1" >
  <xsd:complexType>
    <xsd:sequence>
      <xsd:element ref="HotelGroup" minOccurs="0" maxOccurs="1" />
    </xsd:sequence>
  </xsd:complexType>
</xsd:element>

<xsd:element name="RoomCategory" 
             sql:relation="[alean_descr_RoomCategories]" 
             sql:relationship="DRC"
             sql:key-fields="hotelID RoomTypeShortName RoomCategoryShortName"
             sql:overflow-field="OverflowColumn"
>
  <xsd:complexType>
     <xsd:attributeGroup ref="ids"/>
     <xsd:attribute name="RoomTypeShortName"     type="ShortNameType" sql:datatype="nvarchar(24)" use="required"/>
     <xsd:attribute name="RoomTypeName"          type="xsd:string"    sql:datatype="nvarchar(256)" />
     <xsd:attribute name="RoomCategoryShortName" type="ShortNameType" sql:datatype="nvarchar(24)" />
     <xsd:attribute name="RoomCategoryName"      type="xsd:string"    sql:datatype="nvarchar(256)" />
     <xsd:attribute name="BaseSeatQuantity"      type="xsd:int" />
     <xsd:attribute name="ExtSeatQuantity"       type="xsd:int" />
  </xsd:complexType>
</xsd:element>

<xsd:element name="RoomCategoryList" sql:is-constant="1" >
   <xsd:complexType>
     <xsd:sequence>
        <xsd:element ref="RoomCategory" minOccurs="0" maxOccurs="1" />
     </xsd:sequence>
   </xsd:complexType>
</xsd:element>

<xsd:element name="Hotel" 
             sql:relation="[alean_descrs]" 
             sql:key-fields="hotelID"
             sql:relationship="BHD"
             sql:overflow-field="OverflowColumn"
>
  <xsd:complexType>
    <xsd:sequence>
      <xsd:element ref="TourList" minOccurs="0" maxOccurs="1" />
      <xsd:element ref="HotelGroupList" minOccurs="0" maxOccurs="1" />
      <xsd:element ref="RoomCategoryList" minOccurs="0" maxOccurs="1" />
    </xsd:sequence>
    <xsd:attributeGroup ref="ids"/>
    <xsd:attribute name="HotelName"          type="xsd:string"    sql:datatype="nvarchar(256)" />
    <xsd:attribute name="HotelTypeShortName" type="ShortNameType" sql:datatype="nvarchar(24)" />
    <xsd:attribute name="HotelTypeName"      type="xsd:string"    sql:datatype="nvarchar(256)" />
    <xsd:attribute name="TownName"           type="xsd:string"    sql:datatype="nvarchar(256)" />
    <xsd:attribute name="AreaName"           type="xsd:string"    sql:datatype="nvarchar(256)" />
    <xsd:attribute name="RegionName"         type="xsd:string"    sql:datatype="nvarchar(256)" />
    <xsd:attribute name="CountryName"        type="xsd:string"    sql:datatype="nvarchar(256)" />
    <xsd:attributeGroup ref="Status"/>
 </xsd:complexType>
</xsd:element>

</xsd:schema>


Но для меня так и осталось загадкой: ПОЧЕМУ?
5 мар 16, 09:56    [18899764]     Ответить | Цитировать Сообщить модератору
Все форумы / Microsoft SQL Server Ответить