Bitmask
Bitmask

Reputation: 958

XML Schema - Allow Invalid Dates

Hi I am using biztalk's FlatFile parser (using XML schema) to part a CSV file. The CSV File sometimes contains invalid date - 1/1/1900. Currently the schema validation for the flat file fails because of invalid date. Is there any setting that I can use to allow the date to be used?

I dont want to read the date as string. I might be forced to if there is no other way.

Upvotes: 0

Views: 276

Answers (1)

schellack
schellack

Reputation: 10274

You could change it to a valid XML date time (e.g., 1900-01-00:00:00Z) using a custom pipeline component (see examples here). Or you can just treat it as a string in your schema and deal with converting it later in a map, in an orchestration, or in a downstream system.

Here is a a C# snippet that you could put into a scripting functoid inside a BizTalk map to convert the string to an xs:dateTime, though you'll need to do some more work if you want to handle the potential for bad input data:

public string ConvertStringDateToDateTime(string param1)
{
    return DateTime.Parse(inputDate).ToString("s",System.Globalization.DateTimeFormatInfo.InvariantInfo);
}

Also see this blog post if you're looking to do that in multiple places in a single map.

Upvotes: 2

Related Questions