0
votes

I have a fairly simple flat file schema that just generates CSV, or at least it is supposed to. It has a Root node which is delimited by CRLF, and then a Record node which is delimited by comma, and then the actual fields under that.

<?xml version="1.0" encoding="utf-16" ?>
<xs:schema xmlns="http://My.Namespace" xmlns:b="http://schemas.microsoft.com/BizTalk/2003" targetNamespace="http://My.Namespace" 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 name="Record">
          <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 minOccurs="0" default="" name="TheFirstField" nillable="true" type="xs:string">
                <xs:annotation>
                  <xs:appinfo>
                    <b:fieldInfo justification="left" sequence_number="1" />
                  </xs:appinfo>
                </xs:annotation>
              </xs:element>
              <!-- And more fields here -->
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

When I do a Generate Instance on this schema, I get a file that just has commas, which suggests to me that it is at least somewhat set up right for creating CSV. However, when I have this schema as the output type of a map, from an input type of an XML file, and I do a Test Map, I get this:

Invoking component...
TestMap used the following file: <file:///C:\path\to\test.xml> as input to the map.
C:\path\to\output.xml: error btm1046: Output validation error: The element 'Root' in namespace 'http://My.Namespace' has invalid child element 'Record'.
Test Map failure for map file <file:///C:\path\to\my\Map.btm>. The output is stored in the following file: <file:///C:\path\to\output.txt> 
Component invocation succeeded.

The output.txt file does not end up getting created.

What is the reason for this error when testing the map with a flat file output, and how do I resolve it?

1

1 Answers

0
votes

This error indicates that the generated output from the map doesn't validate with your schema. I tried your example but it works on my machineā„¢. The schema you've provided does allow for the Record element to be a child of Root.

Can you see if the file C:\path\to\output.xml is being created and, if so, does it show the same error when validating against your schema? What happens when you set the Test Map Output to Native instead of XML? Can you also check if your assemblies are up to date in the Global Assembly Cache?