2017-09-21 100 views
0

我有平面文件的XSD從XML映射的結果,像這樣:的BizTalk平面文件產生CRLF即使空數據

<?xml version="1.0" encoding="utf-16"?> 
<xs:schema xmlns="http://mynamespace" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://mynamespace" 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="File" /> 
    </xs:appinfo> 
    </xs:annotation> 
    <xs:element name="File"> 
    <xs:annotation> 
     <xs:appinfo> 
     <b:recordInfo structure="delimited" child_delimiter_type="hex" child_delimiter="0x0D 0x0A" 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 minOccurs="0" maxOccurs="unbounded" name="TransactionDate"> 
      <xs:annotation> 
      <xs:appinfo> 
       <b:recordInfo structure="delimited" child_delimiter_type="hex" child_delimiter="0x0D 0x0A" child_order="infix" sequence_number="1" preserve_delimiter_for_empty_data="true" suppress_trailing_delimiters="false" repeating_delimiter_type="hex" repeating_delimiter="0x0D 0x0A" /> 
      </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 minOccurs="0" maxOccurs="unbounded" name="Items"> 
       <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" repeating_delimiter_type="hex" repeating_delimiter="0x0D 0x0A" /> 
        </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 minOccurs="0" maxOccurs="unbounded" name="Item"> 
         <xs:annotation> 
         <xs:appinfo> 
          <b:recordInfo structure="positional" 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> 
          <!-- My elements here --> 
         </xs:sequence> 
         </xs:complexType> 
        </xs:element> 

        </xs:sequence> 
       </xs:complexType> 
       </xs:element> 
      </xs:sequence> 
      </xs:complexType> 
     </xs:element> 
     <xs:element minOccurs="1" maxOccurs="1" default="EOF" name="EOF" type="xs:string"> 
      <xs:annotation> 
      <xs:appinfo> 
       <b:fieldInfo sequence_number="2" justification="left" pos_offset="0" pos_length="3" /> 
      </xs:appinfo> 
      </xs:annotation> 
     </xs:element> 
     </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
</xs:schema> 

的問題是當XML有數據,我們有一個正確的結果,是這樣的:

line1 
line2 
line3 
EOF 

但是,當我們沒有數據(XML僅僅只有命名空間)

<ns:SAPFile Channel="Eziemall" xmlns:ns="http://mynamespace" /> 

然後平面文件是:

CRLF (for easy reading) 
EOF 

我怎樣才能從我的平面文件擺脫CRLF的,我只是想在EOF的第一道防線。

+1

只是一個猜測:你,不管怎樣,有你的根記錄換行分隔符後綴分隔符?這個後綴分隔符將在EOF之前放置一個換行符。 –

+0

@PieterVandenheede你可能會想到:'preserve_delimiter_for_empty_data =「true」suppress_trailing_delimiters =「false」'表明有一種切換方法。自從我上次使用BizTalk架構編輯器以來已經有一段時間了,所以我無法肯定地回答。 – Filburt

+0

@PieterVandenheede:下面是我所有的xsd文件,(「<! - 我的元素在這裏 - >」我隱藏的部分並不重要,我猜根本沒有後綴 – neitcouq

回答

0

我剛試過你的模式,有一張地圖,我沒有映射任何東西到目的地,我沒有得到CRLF。

所以問題出在你的地圖上,而不是架構上。

如果沒有數據,則需要添加一個鏈接到TransactionDate,以抑制該數據。

enter image description here

+0

非常棒!謝謝Dijkgraaf! – neitcouq