2017-01-11 40 views
0

1つのメッセージが複数の項目を構成する場合、BizTalk 2010のエンベロープでいくつかの実験を実行しようとしています。私は以下のように封筒のスキーマを持っている:無効な子要素

封筒:

<?xml version="1.0" encoding="utf-16"?> 
<xs:schema xmlns="http://TestFromMSDN" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://TestFromMSDN" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:annotation> 
    <xs:appinfo> 
     <b:schemaInfo is_envelope="yes" /> 
    </xs:appinfo> 
    </xs:annotation> 
    <xs:element name="Envelope"> 
    <xs:annotation> 
     <xs:appinfo> 
     <b:recordInfo body_xpath="/*[local-name()='Envelope' and namespace-uri()='http://TestFromMSDN']" /> 
     </xs:appinfo> 
    </xs:annotation> 
    <xs:complexType> 
     <xs:sequence> 
     <xs:any /> 
     </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
</xs:schema> 

個々の項目のためのスキーマは以下の通りです。各エンベロープは複数の項目を含むことができます。私は、XMLデータを作成しようとすると

<?xml version="1.0" encoding="utf-16"?> 
<xs:schema xmlns="http://TestFromMSDN" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" elementFormDefault="qualified" targetNamespace="http://TestFromMSDN" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:element name="Error"> 
    <xs:complexType> 
     <xs:sequence> 
     <xs:element name="ID" type="xs:int" /> 
     <xs:element name="Type" type="xs:int" /> 
     <xs:element name="Priority" type="xs:string" /> 
     <xs:element name="Description" type="xs:string" /> 
     <xs:element name="ErrorDateTime" type="xs:string" /> 
     </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
</xs:schema> 

、BizTalkが私のXMLを好きではないと無効な子要素を言って、私の2番目の項目に波線を持っていました。

enter image description here

誰かが私のデータで間違っているものを指摘することはできますか?デフォルトでは

<ns0:Envelope xmlns:ns0="http://TestFromMSDN"> 
    <ns0:Error> 
    <ns0:ID>102</ns0:ID> 
    <ns0:Type>0</ns0:Type> 
    <ns0:Priority>High</ns0:Priority> 
    <ns0:Description>Sproket query fails</ns0:Description> 
    <ns0:ErrorDateTime>1999-05-31T13:20:00.000-05:00</ns0:ErrorDateTime> 
    </ns0:Error> 
    <ns0:Error> 
    <ID>16502</ID> 
    <Type>2</Type> 
    <Priority>Low</Priority> 
    <Description>Time threshold exceeded</Description> 
    <ErrorDateTime>1999-05-31T13:20:00.000-05:00</ErrorDateTime> 
    </ns0:Error> 
</ns0:Envelope> 

答えて

0

シーケンス内の項目の数は1です。あなたは無制限であることをmaxOccursを指定するか、あなたのEnvelope要素(私は明確にするための注釈を削除した)に期待する項目の正確な数必要があります。

<xs:element name="Envelope"> 
    <xs:complexType> 
    <xs:sequence maxOccurs="unbounded"> 
     <xs:any /> 
    </xs:sequence> 
    </xs:complexType> 
</xs:element> 

もう一つの提案:あなたはEnvelopeのみErrorの要素を期待している場合は、より良い練習が<xs:Error/>代わりの<xs:any/>を指定することです。

+0

maxOccursを指摘していただきありがとうございます。奇妙な警告を出すのも不思議ではありません。 については、だけでなく、何かをうまくキャッチすることが私の目標です。私は将来、エラーメッセージだけでなく、そこに何かを投げることができることを願っています。うまくいけば、これは良い習慣に反するものではない。 – user1205746

関連する問題