PRB: Decimal Separators May Cause Parsing Errors in BizTalk Server 2000 (292514)



The information in this article applies to:

  • Microsoft BizTalk Server 2000

This article was previously published under Q292514

SYMPTOMS

Many locales use a decimal separator other than a period (.). For example, five and three quarters may be represented as 5,75. When you attempt to use this format in BizTalk Server 2000, a document validation error may occur.

CAUSE

BizTalk Server converts data to XML for internal processing. XML only allows a period as a decimal separator. BizTalk Server does not automatically convert numeric fields to the required XML format.

RESOLUTION

To work around this behavior, specify the incoming field as a string, and then use a functoid in the BizTalk Mapper to convert this to a numeric format.

For details on how to implement this scenario, see the example in the "More Information" section of this article.

STATUS

This behavior is by design.

MORE INFORMATION

The self-extracting Separatorparse.exe file contains the sample files that are used in the following steps.

The following file is available for download from the Microsoft Download Center:
The Separatorparse.exe file contains the following files:

File NameSize
Readme.txt256 bytes
Commadoc.txt29 bytes
Flatcommspec.xml1.28 KB (1,320 bytes)
Mapstringtoreal.xml4.15 KB (4,253 bytes)
Sampleoutput.xml114 bytes
Xmloutputspec.xml946 bytes


For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to Obtain Microsoft Support Files from Online Services

Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.

Example

In this example, the incoming data is in a flat file format. The fields are separated with the number sign (#) character and the records are separated with a carriage return. There are two fields per record; the first is the product, and the second is the quantity, which is required in weight. The quantity is a floating point number with a comma (,) as the decimal separator.

The following code represents an order with two items:
#Bananas#1,50
#Grapes#0,25
				
(A sample input file is included in the download file Commadoc.txt.)

This code must be converted to the following XML format:
<Order>
  <Item Produce="Bananas" Tons="1.50"/>
  <Item Produce="Grapes" Tons="0.25"/>
</Order>
				
(Sample output is included in the download file Sampleoutput.xml.)

To perform this conversion, use the following steps:
  1. Use the BizTalk Editor to write a document specification for the flat file format. Both fields of each record in this example are of type string and named "Product" and "Weight."

    (See the download file Flatcommspec.xml for an example of this document specification.)
  2. Use the BizTalk Editor to write a document specification for the XML format. The Produce field is of type string. The Tons field in the Item record in this example has a type of r4.

    (For an example of this document specification, see the Xmloutputspec.xml download file.)
  3. In the BizTalk Messaging Manager, set up a document definition for these specifications named "FlatFileOrder" and "XMLOrder" respectively.
  4. Create an envelope for the flat file specification named "FlatFileEnvelope."
  5. In the BizTalk Mapper, create a new map.

    (For an example of this map specification, see the Mapstringtoreal.xml download file.)

    Set the source document to the flat file specification and the destination document to the XML specification that you created in the previous steps.
  6. Drag the Product field of the source document to the "Produce" field of the destination document.
  7. Use the functoid palette to add a scriptor component.
  8. Drag the Weight field from the source document and input it into the scriptor functoid.
  9. In the scriptor component, set the script to the following:
    Function MyFunction1( p_strParm0 )
      MyFunction1 = Replace(p_strParm0, ",", ".")
    End Function
    						
  10. Drag the output from the scriptor to the Tons field in the destination document.

    Note that the CDbl function in the Microsoft Visual Basic Script is internationally aware and recognizes decimal separators and thousand separators, depending on the locale settings. Therefore, you do not need to convert the commas to periods by using Replace(). If the locale is set correctly, you can use the MyFunction1 = CDbl(p_strParm0) line instead.
  11. Save the map as "FlatToXMLMap."
  12. Create the port to the destination where you want to send the resulting document.
  13. Create a channel to the port named "FlatOrderToXML." Set the incoming document definition to FlatFileOrder, and set the outgoing document definition to XMLOrder. Set the mapping that will be used to FlatToXMLMap.
  14. Submit the sample document and specify the channel and envelope to use. The output document should match the sample XML code (shown above).

Modification Type:MinorLast Reviewed:8/5/2004
Keywords:kbdownload kbdownload kbgraphxlinkcritical kbprb KB292514