命名空间'*'中的元素'Send'在命名空间'*'中具有无效的子元素'Add_Records'。地图文件的测试图失败

时间:2016-02-10 19:18:39

标签: xml xsd biztalk biztalk-mapper

我有以下输入文件:

H|3      |20110607235508
V|M065      |3077999   |NH|PAS|20110608|213400|M| |   
V|M006      |EUR8944   |NY|PAS|20110608|213547|M| |   
V|M057      |UNV39S    |NJ|PAS|20110608|213908|M| |  
T|3      |20110607235508

我有这个架构

<xs:schema xmlns="http://BizTalkNyCase.Schemas.CaseFileSchema" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://BizTalkNyCase.Schemas.CaseFileSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
  <xs:appinfo>
  <schemaEditorExtension:schemaInfo namespaceAlias="b" extensionClass="Microsoft.BizTalk.FlatFileExtension.FlatFileExtension" standardName="Flat File" xmlns:schemaEditorExtension="http://schemas.microsoft.com/BizTalk/2003/SchemaEditorExtensions" /> 
  <b:schemaInfo standard="Flat File" codepage="65001" default_pad_char="" pad_char_type="char" count_positions_by_byte="false" parser_optimization="speed" lookahead_depth="3" suppress_empty_nodes="false" generate_empty_nodes="true" allow_early_termination="false" early_terminate_optional_fields="false" allow_message_breakup_of_infix_root="false" compile_parse_tables="false" root_reference="CaseFileSchema" /> 
  </xs:appinfo>
  </xs:annotation>
  <xs:element name="CaseFileSchema">
  <xs:annotation>
  <xs:appinfo>
  <b:recordInfo structure="delimited" child_delimiter_type="hex" child_delimiter="0xD 0xA" child_order="infix" sequence_number="1" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" /> 
  </xs:appinfo>
  </xs:annotation>
  <xs:complexType>
  <xs:sequence>
  <xs:annotation>
  <xs:appinfo>
  <groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" /> 
  </xs:appinfo>
  </xs:annotation>
  <xs:element name="CaseHeader" type="xs:string">
  <xs:annotation>
  <xs:appinfo>
  <b:fieldInfo justification="left" sequence_number="1" /> 
  </xs:appinfo>
  </xs:annotation>
  </xs:element>
  <xs:element minOccurs="3" maxOccurs="3" name="CaseRecords">
  <xs:annotation>
  <xs:appinfo>
  <b:recordInfo structure="delimited" child_delimiter_type="char" child_delimiter="|" child_order="infix" sequence_number="2" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" /> 
  </xs:appinfo>
  </xs:annotation>
  <xs:complexType>
  <xs:sequence>
  <xs:annotation>
  <xs:appinfo>
  <groupInfo sequence_number="0" xmlns="http://schemas.microsoft.com/BizTalk/2003" /> 
  </xs:appinfo>
  </xs:annotation>
  <xs:element name="Vehicle" type="xs:string">
  <xs:annotation>
  <xs:appinfo>
  <b:fieldInfo justification="left" sequence_number="1" /> 
  </xs:appinfo>
  </xs:annotation>
  </xs:element>
  <xs:element name="Officer_Id" type="xs:string">
  <xs:annotation>
  <xs:appinfo>
  <b:fieldInfo justification="left" sequence_number="2" /> 
  </xs:appinfo>
  </xs:annotation>
  </xs:element>
  <xs:element name="Vehicle_Tag" type="xs:string">
  <xs:annotation>
  <xs:appinfo>
  <b:fieldInfo justification="left" sequence_number="3" /> 
  </xs:appinfo>
  </xs:annotation>
  </xs:element>
  <xs:element name="State" type="xs:string">
  <xs:annotation>
  <xs:appinfo>
  <b:fieldInfo justification="left" sequence_number="4" /> 
  </xs:appinfo>
  </xs:annotation>
  </xs:element>
  <xs:element name="Vehicle_Type" type="xs:string">
  <xs:annotation>
  <xs:appinfo>
  <b:fieldInfo justification="left" sequence_number="5" /> 
  </xs:appinfo>
  </xs:annotation>
  </xs:element>
  <xs:element name="TowDate" type="xs:string">
  <xs:annotation>
  <xs:appinfo>
  <b:fieldInfo justification="left" sequence_number="6" /> 
  </xs:appinfo>
  </xs:annotation>
  </xs:element>
  <xs:element name="TowTime" type="xs:string">
  <xs:annotation>
  <xs:appinfo>
  <b:fieldInfo justification="left" sequence_number="7" /> 
  </xs:appinfo>
  </xs:annotation>
  </xs:element>
  <xs:element name="TowType" type="xs:string">
  <xs:annotation>
  <xs:appinfo>
  <b:fieldInfo justification="left" sequence_number="8" /> 
  </xs:appinfo>
  </xs:annotation>
  </xs:element>
  <xs:element name="TowIndicator" type="xs:string">
  <xs:annotation>
  <xs:appinfo>
  <b:fieldInfo justification="left" sequence_number="9" /> 
  </xs:appinfo>
  </xs:annotation>
  </xs:element>
  <xs:element name="Precinct" type="xs:string">
  <xs:annotation>
  <xs:appinfo>
  <b:fieldInfo justification="left" sequence_number="10" /> 
  </xs:appinfo>
  </xs:annotation>
  </xs:element>
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  <xs:element name="CaseTrailer" type="xs:string">
  <xs:annotation>
  <xs:appinfo>
  <b:fieldInfo justification="left" sequence_number="3" /> 
  </xs:appinfo>
  </xs:annotation>
  </xs:element>
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  </xs:schema>

这是输出架构

<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://SqlAdapterCase" version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:annotation>
  <xs:appinfo>
  <msbtssql:sqlScript value="exec [Add_Records] @OfficerId=" ", @Precinct=" ", @State=" ", @TowDate=" ", @TowIndicator=" ", @TowTime=" ", @TowType=" ", @Vehicle=" ", @VehicleTag=" ", @VehicleType=" "" xmlns:msbtssql="http://schemas.microsoft.com/BizTalk/2003" /> 
  </xs:appinfo>
  </xs:annotation>
  <xs:element name="Send">
  <xs:complexType>
  <xs:sequence>
  <xs:element name="Add_Records">
  <xs:complexType>
  <xs:attribute name="OfficerId" type="xs:string" /> 
  <xs:attribute name="Precinct" type="xs:string" /> 
  <xs:attribute name="State" type="xs:string" /> 
  <xs:attribute name="TowDate" type="xs:string" /> 
  <xs:attribute name="TowIndicator" type="xs:string" /> 
  <xs:attribute name="TowTime" type="xs:string" /> 
  <xs:attribute name="TowType" type="xs:string" /> 
  <xs:attribute name="Vehicle" type="xs:string" /> 
  <xs:attribute name="VehicleTag" type="xs:string" /> 
  <xs:attribute name="VehicleType" type="xs:string" /> 
  </xs:complexType>
  </xs:element>
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  <xs:element name="Recive">
  <xs:complexType>
  <xs:sequence>
  <xs:element name="Success" type="xs:anyType" /> 
  </xs:sequence>
  </xs:complexType>
  </xs:element>
  </xs:schema>

然而,当我测试地图时,我收到此错误

  作为   输入到地图。 C:\ Users \ Administrator \ Desktop \ error.xml:错误   btm1046:输出验证错误:名称空间中的元素“发送”   “http://SqlAdapterCase”中包含无效的子元素“Add_Records”   名称空间“http://SqlAdapterCase”。地图文件的测试图失败

1 个答案:

答案 0 :(得分:3)

看到你的地图和/或输出信息完全回答这个问题很重要,但是看看你的输出模式,所有的值都是必需的(minOccurs没有指定,这意味着它默认为1)。

您有几个选择:

  1. 如果某些节点确实不是必需的,并且您希望架构与其一致,请更新架构,以便不需要的属性/元素上有minOccurs="0"
  2. 更新地图,以便为所有必需的节点/属性(当前所有节点/属性)提供有效输出。即使是空字符串(或将节点Value属性设置为<Empty>也可以)。
  3. 关闭映射器上的验证。我通常这样做 - 很多时候,开发人员不打扰设置minOccurs="0",并且BizTalk运行时不会进行验证检查,除非您专门使用验证管道组件(或其他一些自定义验证组件)。地图单元测试通常更关注其他事项,而不是是否遵循所有模式规则默认情况下,这些属性设置为 True - 将其更改为false。如果您想再次验证,可以随后将其更改回来。
  4. Map properties