2017-09-27 66 views
0

我有一个像这样的分隔文件。BizTalk架构 - 使字段元素标记名称相同标题

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文件。有没有更简单的方法来实现这一目标?

+0

没有,你只需要更新它们,平面文件向导不幸的是,在标题行中没有智能选项。您可以在平面文件向导中重命名它们,但这更加乏味。 – Dijkgraaf

回答

-1

我认为只有平面文件架构是不可能的。您需要实施地图并创建这些标签并分配值。

例如,与此平面文件架构:

<?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> 
+0

您可以毫无问题地重命名平面文件架构中的元素,实际上这是很好的做法。 – Dijkgraaf

+0

问题是如果可以自动执行,因为他有很多字段,并且在我的回复中我使用地图生成了所需的标签。 – felixmondelo

+0

虽然输出XSD文件?如果您的XSLT可以接受XSD文件并重命名元素,再加上删除或修改第一句(这是不正确的),那么您的答案将是正确的。 – Dijkgraaf