BizTalk架构-使字段元素标记名称与标题相同

BizTalk架构-使字段元素标记名称与标题相同,biztalk,biztalk-schemas,Biztalk,Biztalk Schemas,我有一个这样的分隔文件 Name;ID;Type ABC;1;Blue PQR;2;Black 我正在尝试为上述数据创建一个平面文件模式。但我无法找到一种方法使XML标记与标题匹配 它正在创建的XML文件是 <Root> <Root_Child1>Root_Child</Root_Child1> <Root_Child2>Root_Child</Root_Child2> <Root_Child3>Root_Child<

我有一个这样的分隔文件

Name;ID;Type
ABC;1;Blue
PQR;2;Black
我正在尝试为上述数据创建一个平面文件模式。但我无法找到一种方法使XML标记与标题匹配

它正在创建的XML文件是

<Root>
<Root_Child1>Root_Child</Root_Child1>
<Root_Child2>Root_Child</Root_Child2>
<Root_Child3>Root_Child</Root_Child3>
</Root>

根儿童
根儿童
根儿童
我想要的是这样的东西

<Root>
<Name>Root_Child</Name>
<ID>Root_Child</ID>
<Type>Root_Child</Type>
</Root>

根儿童
根儿童
根儿童

我有55个头,手动更改XSD文件是一项乏味的工作。有没有更简单的方法来实现这一点?

我认为仅使用平面文件模式是不可能的。您需要实现一个映射,创建这些标记并分配值

例如,使用此平面文件架构:

<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns:b="http://schemas.microsoft.com/BizTalk/2003" xmlns="http://BizTalkMassCopy.FlatFileSchema8" targetNamespace="http://BizTalkMassCopy.FlatFileSchema8" 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="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="Headers">
          <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="Headers_Child1" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" sequence_number="1" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
              <xs:element name="Headers_Child2" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" sequence_number="2" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
              <xs:element name="Headers_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:element maxOccurs="unbounded" name="Item">
          <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="Item_Child1" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" sequence_number="1" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
              <xs:element name="Item_Child2" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" sequence_number="2" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
              <xs:element name="Item_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>

然后使用以下自定义XSLT实现映射:

<?xml version="1.0" encoding="UTF-16"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var s0" version="1.0" xmlns:s0="http://BizTalkMassCopy.FlatFileSchema8" xmlns:ns0="http://BizTalkMassCopy.Schema2">
  <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
  <xsl:template match="/">
    <xsl:apply-templates select="/s0:Root" />
  </xsl:template>
  <xsl:template match="/s0:Root">
    <xsl:variable name="var:v1" select="Headers/Headers_Child1/text()" />
    <xsl:variable name="var:v2" select="Headers/Headers_Child2/text()" />
    <xsl:variable name="var:v3" select="Headers/Headers_Child3/text()" />

    <ns0:Root>
      <xsl:for-each select="Item">
        <xsl:element name="Items">
          <xsl:element name="{$var:v1}">
            <xsl:value-of select="Item_Child1" />
          </xsl:element>
          <xsl:element name="{$var:v2}">
            <xsl:value-of select="Item_Child2" />
          </xsl:element>
          <xsl:element name="{$var:v3}">
            <xsl:value-of select="Item_Child3" />
          </xsl:element>
        </xsl:element>
      </xsl:for-each>
    </ns0:Root>
  </xsl:template>
</xsl:stylesheet>


不,您只需更新它们,很遗憾,“平面文件向导”没有足够的智能来识别标题行中的名称。您可以在平面文件向导中重命名它们,但这更为繁琐。您可以在平面文件架构中重命名元素而不会出现任何问题,这样做实际上是一种很好的做法。问题是是否可以自动执行此操作,因为他有很多字段,在我的回答中,我给出了一个使用映射生成所需标记的解决方案。但是输出是XSD文件吗?如果XSLT可以获取XSD文件并重命名元素,再加上删除或修改第一句话(这是不正确的),那么您的答案将是正确的。