2010-11-18 5 views
0

誰かが私を助けてくれることを願っています。私はこれでとても新しいです。それは(sql:relation attributeなどを使用して)複数 SQLテーブルにXMLデータをダンプするXSDスキーマを取得することが可能ですかと思いまして。XMLデータをSQLテーブルに入れるためのXSDスキーマの作成

一つのテーブルには何の問題も証明されていないので、それは二つにデータをダンプすることが可能です場合、私はちょうど疑問に思いました。 1つのXSDスキーマでこれを行うことができればうれしいですが、2番目のテーブルで2回XMLを渡す必要がありますか?

ありがとうございます。


がここにスキーマそのものです:

<?xml version="1.0" encoding="UTF-8"?> 
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sql="urn:schemas-microsoft-com:mapping-schema"> 
<!-- Skimlinks/Everyfeed schema --> 

<!-- definition of simple elements --> 
<xs:element name="title" type="xs:string" sql:field="ProductName"/> 
<xs:element name="url" type="xs:string" sql:field="ProductURL"/> 
<xs:element name="image_url" type="xs:string" sql:field="ImageURL"/> 
<xs:element name="currency" type="xs:string" sql:field="currency"/> 
<xs:element name="price" type="xs:string" sql:field="Price"/> 
<xs:element name="merchant" type="xs:string" sql:field="Brand" default=" " /> 
<xs:element name="description" type="xs:string" sql:field="Description" default=" "/> 
<xs:element name="item" type="xs:string" sql:field="Category" /> 

<!-- definition of attributes --> 
<xs:attribute name="id" type="xs:string" sql:field="SKU" /> 

<!-- definition of complex elements --> 
<xs:element name="category" sql:relation="ProductDataCategory"> 
    <xs:complexType> 
    <xs:sequence> 
     <xs:element ref="item" maxOccurs="unbounded"/> 
    </xs:sequence> 
    </xs:complexType> 
</xs:element> 

<xs:element name="product" sql:relation="ProductData"> 
    <xs:complexType> 
    <xs:sequence> 
     <xs:element ref="title"/> 
     <xs:element ref="url"/> 
     <xs:element ref="image_url"/> 
     <xs:element ref="currency"/> 
     <xs:element ref="price"/> 
     <xs:element ref="merchant"/> 
     <xs:element ref="description"/> 
     <xs:element ref="category"/> 
    </xs:sequence> 
    <xs:attribute ref="id" use="required"/> 
    </xs:complexType> 
</xs:element> 

<xs:element name="products" sql:is-constant="1"> 
    <xs:complexType> 
    <xs:sequence> 
     <xs:element ref="product" maxOccurs="unbounded"/> 
    </xs:sequence> 
    </xs:complexType> 
</xs:element> 

<xs:element name="everyFeed" sql:is-constant="1"> 
    <xs:complexType> 
    <xs:sequence> 
     <xs:element ref="products" maxOccurs="1" /> 
    </xs:sequence> 
    </xs:complexType> 
</xs:element> 

</xs:schema> 

ここでは、インポートしているXMLの例です:

<?xml version='1.0' encoding='utf-8'?> 
<feed version="2"> 
<numFound>7985</numFound> 
<products> 
    <product id="18639|216623247"> 
     <title>Trouser</title> 
     <url>http://www.products.com/trousers/trouser/</url> 
     <image_url>http://www.images.co.uk/images/big/4d624426.jpg</image_url> 
     <verified_image>True</verified_image> 
     <currency>GBP</currency> 
     <price>1000</price> 
     <prev_price>1000</prev_price> 
     <firstseen>2010-10-27T00:00:00Z</firstseen> 
     <lastseen>2010-10-27T00:00:00Z</lastseen> 
     <merchant id="20748">Yours Clothing</merchant> 
     <by>Yours Clothing</by> 
     <description></description> 
     <category> 
     <item id="9">Lounge &amp; nightwear</item> 
     <item id="3">Women</item> 
     <item id="2">Clothing</item> 
     <item id="1">Clothing, shoes &amp; accessories</item> 
     </category> 
    </product> 
</products> 
</feed> 

あなたが見ることができるように、それは二つのテーブルにダンプしようとします。 ProductDataおよびProductDataCategory。後者のテーブル(フィールドカテゴリ)には、<item>要素に格納されているものだけが必要です。

エラーメッセージは、読み取ります!

Error: Relationship expected on 'category'

を、私はこの作業を得ることにどのような援助のために、なぜ:(

感謝を知らない

+1

@Django - これはXMLスキーマのMicrosoft固有の拡張機能であるため、私はタグを付け直しました。 – Anon

+0

あなたは何をしようとしているのか詳細を知りたいでしょう。このスキーマを使用して、データを1つのテーブルに一括ロードするにはどうしたらよいですか? –

+0

こんにちはJohn、詳細はこちらhttp://stackoverflow.com/questions/3373104/problem-during-sql-bulk-load –

答えて

1

あなたは、SQLを定義する必要があるかもしれませんあなたが一括インポートを実行しようとしている場合、XSDファイル内の関係。同じ問題が発生しました(これはあなたのXSDに固有の例ではありません)。

<xs:annotation> 
    <xs:appinfo> 
     <sql:relationship name="Detail" 
         parent="Product" 
         parent-key="ProductID" 
         child="Details" 
         child-key="ProductID" 
         /> 
     <sql:relationship name="ProductFiles" 
         parent="Product" 
         parent-key="ProductID" 
         child="Files" 
         child-key="ProductID" 
         /> 
     <sql:relationship name="ProductToList" 
         parent="Product" 
         parent-key="ProductID" 
         child="ProductList" 
         child-key="ProductID" 
         /> 
     <sql:relationship name="ListToProduct" 
         parent="ProductList" 
         parent-key="ID" 
         child="ProductListProduct" 
         child-key="ProductListID" 
         /> 
    </xs:appinfo> 
    </xs:annotation> 
+0

あなたの答えをありがとう。私のXSDスキーマファイルはすでにSQLの関係を定義しています...それがどのように修正できるか、さらに具体的な情報がありますか? –

+0

ああ、私があなたが投稿した医者には見たことがありませんでした。私が関係を定義した後に修正した問題として他に何が起こっているのかは分かりません。 GL! –

1

ジャンゴ、

DBVisような何かしようとしないのはなぜ - http://www.dbvis.com/ - XSDが生成された図と一致した方に、データベースや作業中のすべての関係を視覚的に表現を作成します。これにより、これらの関係をすべて確実に得ることができます。

は非常に単純なデータベースの例screeshotについてはこちらを参照してください - http://www.dbvis.com/products/dbvis/doc/main/doc/ug/databaseExplorer/images/genericschemaview.png

私はそれがあまりにもはるかに大きいデータベースのためによく働くために保証することができます。

うまくいけば、これはお手伝いします。

関連する問題