January 4, 2013 at 2:47 PM
A week ago, I had a problem with a Flat File Schema in BizTalk 2010. I thought I was doing everything right, but I forgot one important thing.
Below you can find the flat file we have to create a schema for.
N John Smith
A Fakestreet 123 New York USA
A Fakestreet 123 Newark USA
N Mathieu Vermote
A Fakestreet 123 Ghent Belgium
A Fakestreet 123 Roeselare Belgium
N Jane Doe
A Fakestreet 123 Los Angeles USA
A Fakestreet 123 Santa Cruz USA
A Fakestreet 123 San Francisco USA
N Jack Doe
N Jake Doe
A Fakestreet 123 Miami USA
A Fakestreet 123 Fort Lauderdale USA
So we have two type of lines, a name-line (starts with N) and a address-line (starts with A).
In the schema there should be a sequence with N and A repeating and A can occur 0 to many times.
So I made a schema looking like this:
The minOccurs and maxOccurs set to this:
N: 0 – 1
A: 0 – unbounded
The Tag Identifier is also set to ‘N ‘ for element Name and to ‘A ‘ for the element Address.
When I try to ‘Validate Instance’ in Visual Studio I get the error:
Unexpected data found while looking for: ‘A ‘
The solution to this error was to set the Parser Optimization to Complexity.
When the Parser Optimization is set to ‘speed’, which is the default value, the schema is optimized to decrease the parsing time. This is no problem for the most flat files, but for complex flat files it can be a problem.
So setting the value to ‘complexity’ can help your flat file schema parse complex flat files.
More info about the Parse Optimization property on MSDN: http://msdn.microsoft.com/en-us/library/aa578137.aspx