Biztalk:Mapping Excel 文件 OutXML(嵌套列)到自定义架构。

Biztalk:Mapping Excel file OutXML (nested columns) to custom Schema.

我创建了一个自定义管道组件,它使用 OpenXML 方法 here 从 Excel 工作簿中提取 XML 数据。工作簿中的 'raw' XML 具有此架构(从上面引用的 OpenXML 代码中提取的 XML 的实例生成:

    <?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:import schemaLocation=".\Smart Recruiters_ExcelRawXML.xsd" namespace="http://www.w3.org/XML/1998/namespace" />
  <xs:annotation>
    <xs:appinfo>
      <references xmlns="http://schemas.microsoft.com/BizTalk/2003">
        <reference targetNamespace="http://www.w3.org/XML/1998/namespace" />
      </references>
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="Root">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="dimension">
          <xs:complexType>
            <xs:attribute name="ref" type="xs:string" use="required" />
          </xs:complexType>
        </xs:element>
        <xs:element name="sheetViews">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="sheetView">
                <xs:complexType>
                  <xs:attribute name="tabSelected" type="xs:boolean" use="required" />
                  <xs:attribute name="workbookViewId" type="xs:unsignedByte" use="required" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="sheetFormatPr">
          <xs:complexType>
            <xs:attribute name="defaultRowHeight" type="xs:decimal" use="required" />
          </xs:complexType>
        </xs:element>
        <xs:element name="sheetData">
          <xs:complexType>
            <xs:sequence>
              <xs:element maxOccurs="unbounded" name="row">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element maxOccurs="unbounded" name="c">
                      <xs:complexType>
                        <xs:sequence minOccurs="0">
                          <xs:element name="is">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="t">
                                  <xs:complexType>
                                    <xs:simpleContent>
                                      <xs:extension base="xs:string">
                                        <xs:attribute ref="xml:space" use="optional" />
                                      </xs:extension>
                                    </xs:simpleContent>
                                  </xs:complexType>
                                </xs:element>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                        <xs:attribute name="r" type="xs:string" use="required" />
                        <xs:attribute name="s" type="xs:unsignedByte" use="required" />
                        <xs:attribute name="t" type="xs:string" use="optional" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                  <xs:attribute name="r" type="xs:unsignedShort" use="required" />
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="pageMargins">
          <xs:complexType>
            <xs:attribute name="left" type="xs:decimal" use="required" />
            <xs:attribute name="right" type="xs:decimal" use="required" />
            <xs:attribute name="top" type="xs:decimal" use="required" />
            <xs:attribute name="bottom" type="xs:decimal" use="required" />
            <xs:attribute name="header" type="xs:decimal" use="required" />
            <xs:attribute name="footer" type="xs:decimal" use="required" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

第一行第一个元素的例子是:

<x:row r="1"><x:c r="A1" s="1" t="inlineStr"><x:is><x:t>ID</x:t></x:is>

我的问题是,如何在映射器中使用它来遍历列记录并将每个 row/column 值应用到正确的 row/field在目标 XML 中(下)。我在网上搜索过,但我还没有看到任何可以评估该行并应用于正确目标的东西 row/field。假设输入将始终具有正确的列数,即使 'c' 被声明为无界。

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://Schemas.SmartRecruiters_Joibs_Manual" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://Schemas.SmartRecruiters_Joibs_Manual" 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="Root" />
    </xs:appinfo>
  </xs:annotation>
  <xs:element name="Root">
    <xs:annotation>
      <xs:appinfo>
        <b:recordInfo structure="delimited" child_delimiter_type="hex" child_delimiter="0xD 0xA" child_order="postfix" 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 maxOccurs="unbounded" name="Root_Child1">
          <xs:annotation>
            <xs:appinfo>
              <b:recordInfo structure="delimited" child_delimiter_type="char" child_delimiter="," 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="Root_Child1_Child1" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" sequence_number="1" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
              <xs:element name="Root_Child1_Child2" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" sequence_number="2" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
              <xs:element name="Root_Child1_Child3" 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:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

您需要为每个目标行使用值映射。

作为第一个参数的输入是验证原点的行和列是否符合您预期的结果(在本例中,r = 1 且 c.r = A1)。

第二个参数是您要分配的值。

我觉得你有点想多了。

Link <row><Root_Child1> 通过 循环 Functoid。这将在行上循环,值无关紧要......除非你真的需要它。

然后,通过 Index Functoid<t> 连接到 select 第 n 个 <c> 获取值的位置。