2012-06-20 55 views
1

我正在傳遞一大塊XML用於在BizTalk中進行處理。 XML是主要的形式:如何在BizTalk中處理此XML

<FieldItem> 
    <Name>EmploymentStatus</Name> 
    <Value xsi:type="xsd:string">1</Value> 
</FieldItem> 

然而,偶爾一個名稱值對變得更加複雜,看起來像這樣:

<FieldItem> 
     <Name>EducationAndQualifications</Name> 
     <Value xsi:type="RepeatingFieldArray"> 
      <Fields> 
       <RepeatingField> 
        <Items> 
         <FieldItem> 
          <Name>Qualification</Name> 
          <Value xsi:type="xsd:string">umbraco</Value> 
         </FieldItem> 
         <FieldItem> 
          <Name>Establishment</Name> 
          <Value xsi:type="xsd:string">IBM</Value> 
         </FieldItem> 
         <FieldItem> 
          <Name>DateAchieved</Name> 
          <Value xsi:type="xsd:string">June 2011</Value> 
         </FieldItem> 
        </Items> 
       </RepeatingField> 
      </Fields> 
     </Value> 
    </FieldItem> 

我已經通過BizTalks生成項目嚮導但試圖生成模式它不能應付變化的類型,以及可能或不可能存在的附加重複字段。

因此,我正在尋求有關此方面最佳方法的建議/指導。是否有可能創建一個BizTalk想要處理的模式?或者,我現在偏愛的解決方案是否應該創建一個自定義管道組件,將其拆分爲單獨的消息?

謝謝你的時間。

UPDATE

如果我創建了以下模式:

<?xml version="1.0" encoding="utf-16" ?> 
<xsd:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
<xsd:element name="FormData"> 
    <xsd:complexType> 
     <xsd:sequence> 
      <xsd:element name="FormName" type="xsd:string" /> 
      <xsd:element name="FormInstanceId" type="xsd:string" /> 
      <xsd:element name="Status" type="xsd:string" /> 
      <xsd:element name="Data"> 
       <xsd:complexType> 
        <xsd:sequence> 
         <xsd:element maxOccurs="unbounded" name="FieldItem"> 
          <xsd:complexType> 
           <xsd:sequence> 
            <xsd:element name="Name" type="xsd:string" /> 
            <xsd:element minOccurs="0" maxOccurs="unbounded" name="Value" nillable="true" type="xsd:anyType" /> 
           </xsd:sequence> 
          </xsd:complexType> 
         </xsd:element> 
        </xsd:sequence> 
       </xsd:complexType> 
      </xsd:element> 
     </xsd:sequence> 
    </xsd:complexType> 

我收到以下錯誤:

這是一個無效的xsi:type 'RepeatingFieldArray'

所以我仍然傾向於oward寫一些代碼來排序這一切......

回答

1

我已經決定下去自定義管道組件的路線提取重複數據到一個通用的模式,也匹配一般重複鍵/值對。我添加了其他字段,以便每個消息都可以通過它的部分進行標識。見下:

<?xml version="1.0" encoding="utf-16" ?> 
    <xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns0="https://BizTalk.Interfaces.INT034.Schemas.PropertySchema" attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:annotation> 
    <xs:appinfo> 
    <b:imports xmlns:b="http://schemas.microsoft.com/BizTalk/2003"> 
     <b:namespace prefix="ns0" uri="https://BizTalk.Interfaces.INT034.Schemas.PropertySchema" location=".\PropertySchema.xsd" /> 
     </b:imports> 
     </xs:appinfo> 
     </xs:annotation> 
    <xs:element name="Root"> 
    <xs:annotation> 
    <xs:appinfo> 
    <b:properties> 
     <b:property name="ns0:Interface" xpath="/*[local-name()='Root' and namespace-uri()='']/*[local-name()='Interface' and namespace-uri()='']" /> 
     </b:properties> 
     </xs:appinfo> 
     </xs:annotation> 
    <xs:complexType> 
    <xs:sequence> 
     <xs:element name="Interface" type="xs:string" /> 
     <xs:element name="Type" type="xs:string" /> 
     <xs:element name="FormName" type="xs:string" /> 
     <xs:element name="FormInstanceId" type="xs:string" /> 
     <xs:element name="Status" type="xs:string" /> 
    <xs:element name="Data"> 
    <xs:complexType> 
    <xs:sequence> 
    <xs:element maxOccurs="unbounded" name="FieldItem"> 
    <xs:complexType> 
    <xs:sequence> 
     <xs:element name="Name" type="xs:string" /> 
     <xs:element name="Value" type="xs:string" /> 
     </xs:sequence> 
     </xs:complexType> 
     </xs:element> 
     </xs:sequence> 
     </xs:complexType> 
     </xs:element> 
     </xs:sequence> 
     </xs:complexType> 
     </xs:element> 
     </xs:schema>