Managed File Transfer

 View Only

Suppressing XML validation errors in log files

By Tanvi Kakodkar posted Mon February 24, 2020 01:57 AM

  
Originally updated on September 27, 2017 by SwathiBN

Reviewer :  Vincent Tkac, STSM for Sterling B2B Integrator Group.

 

XML validation without a DTD results in unwanted error messages to be written out to the noapp.log.timestamp file                                            

We often notice the noapp log file fills up fast with error messages.

A sample excerpt of the error messages is shown below.

 

[2017-05-25 05:10:12.062] ALL 000000000000 GLOBAL_SCOPE [Error] :1:46: Document root element "result", must match DOCTYPE root "null".
[2017-05-25 05:10:12.506] ALL 000000000000 GLOBAL_SCOPE [Error] :1:46: Document is invalid: no grammar found.

 

In most of the use cases, people operate on XML docs with no validation or DTD involved. This causes many error messages to be thrown into the noapp.log.timestamp file and can cause logs to roll over hiding the true errors thrown by the SI application. 

 

There are several ways of suppressing this error messages to be written out to the log file.

 

Approach 1- Making use of the DTD

Check-in the DTD referenced in the DOCTYPE into Sterling Integration Suite.

  1. Under the Deployment menu choose 'Schema'.
  2. Click Go next to 'Check in a new XML Schema or DTD'.
  3. Select the Schema or DTD file, add comments and complete the check in.

 

Approach 2 – Making changes at the BP level

You can use the extra parameters in the the DocToDOM function to turn off validation of the XML document, especially if no DTD or schema is defined for the document.

Syntax of DocToDOM:

DocToDOM (xpath expression [, validate, loadDTD])

  • validate – Document validation value. Default value is true. Optional.
  • loadDTD – Determines if the parser loads the DTD, as specified. Default value is true. Optional.

The following assign statement will not throw any errors to the noapp.log.timestamp file :

<assign to="." from="DocToDOM(PrimaryDocument, 'false')" />

 

Testing the fix:-

1. Check-in the below sample BP into SI

<process name="DocToDOM_Test">

                        <sequence>

                        <assign to="My_Primary_Document"

from="DocToDOM(PrimaryDocument)">

</assign>

<assign to="GotFirstName" from="//InputDocumentRoot/NodeLeve1/Name/text()">

</assign>

                        </sequence>

      </process>


2. Create a test.xml file with the below contents in it

<?xml version="1.0" encoding="UTF-8"?>

<InputDocumentRoot>

<NodeLeve1>

<Name>John</Name>

<Class type="travel">First</Class>

<BasicInfo>

<age>50</age>

<weight>70</weight>

</BasicInfo>

</NodeLeve1>

 

<NodeLeve2>

<Name>Michael</Name>

<Class type="travel">Second</Class>

<BasicInfo>

<age>100</age>

<weight>150</weight>

</BasicInfo>

</NodeLeve2>

</InputDocumentRoot>

 
3. Execute DocToDOM_Test BP by passing the test.xml as the input file.

4. Upon executing the BP, check the noapp.log.timestamp file for the error messages.

5. Now edit the BP to change the assign statement to the following

<assign to="My_Primary_Document"

from="DocToDOM(PrimaryDocument, 'false')">

</assign>

6. Re-execute the BP by passing test.xml file and verify no new errors messages going to the noapp.log.timestamp file.

 

Approach 3 – Making changes at the global/application level

With SI version 5020500 and above we have introduced a new property called DocToDOMValidate in xmlParsers.properties file which is set to true by default.

 Setting this property to false will turn off the validation which in turn suppresses the noapp.log filling up with the error messages when a DTD isn't specified in the XML document.

 

Testing the fix :-

1. Check in the below sample BP into SI

<process name="DocToDOM_Test">

                        <sequence>

                        <assign to="My_Primary_Document"

from="DocToDOM(PrimaryDocument)">

</assign>

<assign to="GotFirstName" from="//InputDocumentRoot/NodeLeve1/Name/text()">

</assign>

                        </sequence>

      </process>


2. Create an test.xml file with the below contents in it.

<?xml version="1.0" encoding="UTF-8"?>

<InputDocumentRoot>

<NodeLeve1>

<Name>John</Name>

<Class type="travel">First</Class>

<BasicInfo>

<age>50</age>

<weight>70</weight>

</BasicInfo>

</NodeLeve1>

 

<NodeLeve2>

<Name>Michael</Name>

<Class type="travel">Second</Class>

<BasicInfo>

<age>100</age>

<weight>150</weight>

</BasicInfo>

</NodeLeve2>

</InputDocumentRoot>

 
3. Execute DocToDOM_Test BP by passing the test.xml as the input file.

4. Upon executing the BP, check the noapp.log.timestamp file for the error messages.

5. Stop SI.

6. Edit the xmlParsers.properties file and change the value of DocToDOMValidate to false.

7. Restart SI and re-execute the BP by passing test.xml file and verify no new errors messages going to the noapp.log.timestamp file

 


#DataExchange
#IBMSterlingB2BIntegratorandIBMSterlingFileGatewayDevelopers
0 comments
27 views

Permalink