ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » IIB9 - DFDL Parser - Expected exception is not occuring

Post new topic  Reply to topic
 IIB9 - DFDL Parser - Expected exception is not occuring « View previous topic :: View next topic » 
Author Message
vijragem
PostPosted: Mon Nov 13, 2017 1:38 am    Post subject: IIB9 - DFDL Parser - Expected exception is not occuring Reply with quote

Novice

Joined: 09 Jan 2015
Posts: 14

Hi,

I have an interface in IIB9 which reads a Fixed length file of Header, Records and Trailer.

When I run an invalid file which has wrong length in one of the record, the DFDL throws an error on the record in the DFDL trace and immediately, it started mapping the record to trailer and fails there. So, the final exception I am getting is that there is length issue terminator is not found for the trailer. But the actual error is in the record part.

I am seeing that this is an usual behavior by the DFDL as when it see a failure in a record, it goes to trailer part.

Is there any way I can avoid this, so that I can get only the exact error when there is a parser failure.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Nov 13, 2017 5:42 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

If you just defined your records as header, body, trailer without any discriminator or way to identify the record then this is expected behavior.

The DFDL parser tries to evaluate the record in question as a body, fails and tries to evaluate the record as the next type (trailer) and fails again. At this time there is no other valid type to evaluate and the final error gets thrown.

If you had a discriminator to evaluate the record type, the DFDL parser would recognize the record as of type body, recognize that there is a mismatch in the definition and raise the error on the faulty body type.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
timber
PostPosted: Mon Nov 13, 2017 2:44 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

I was about to point out the same thing.

You need to add a discriminator that evaluates to true as soon as you know for sure that you are parsing a body record. That will prevent the parser from backing out and trying the alternative (the trailer). If the body record has a tag then your task is simple. If not, you may have to get creative.
Back to top
View user's profile Send private message
vijragem
PostPosted: Tue Nov 14, 2017 1:11 am    Post subject: Reply with quote

Novice

Joined: 09 Jan 2015
Posts: 14

I agree to add discriminator. I need help to define that as an expression that will inform the parser that what is being parsed is a body. Can you help on the sample expression here please.

fjb_saper wrote:
If you just defined your records as header, body, trailer without any discriminator or way to identify the record then this is expected behavior.

The DFDL parser tries to evaluate the record in question as a body, fails and tries to evaluate the record as the next type (trailer) and fails again. At this time there is no other valid type to evaluate and the final error gets thrown.

If you had a discriminator to evaluate the record type, the DFDL parser would recognize the record as of type body, recognize that there is a mismatch in the definition and raise the error on the faulty body type.

Have fun
Back to top
View user's profile Send private message
vijragem
PostPosted: Tue Nov 14, 2017 1:25 am    Post subject: Reply with quote

Novice

Joined: 09 Jan 2015
Posts: 14

Can you give me an expression for discriminator that set that evaluates to true for the body.

timber wrote:
I was about to point out the same thing.

You need to add a discriminator that evaluates to true as soon as you know for sure that you are parsing a body record. That will prevent the parser from backing out and trying the alternative (the trailer). If the body record has a tag then your task is simple. If not, you may have to get creative.
Back to top
View user's profile Send private message
timber
PostPosted: Tue Nov 14, 2017 6:48 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

A discriminator is an XPath expression. I cannot provide an XPath if I do not know
a) the names of the structures and fields in your DFDL model and
b) the data format that you are parsing

You will need to do some work at your end, and come back with questions that are more specific.
Back to top
View user's profile Send private message
vijragem
PostPosted: Tue Nov 14, 2017 7:01 am    Post subject: Reply with quote

Novice

Joined: 09 Jan 2015
Posts: 14

Okay, Somehow I try to set the discriminator for the body part. I am not sure what I've done is right but requesting you guys to validate it.

CHANGES DONE:

I have added the discriminator in the body part that uses the
below expressions {fn:exists(/EmployeeReports/Reports)}. Please note that Reports is my body.

<dfdl:discriminator>{fn:exists(/EmployeeReports/Reports)}</dfdl:discriminator> (I cannot share the entire DFDL structure here)


TEST1:

I parsed a valid test file which has 1 header, 12 body and 1 trailer. The entire parsing is successful. But, when the 12th record in the body is parsed, the DFDL took the trailer record from the file and started parsing it as body and once it founds the length issue, error is raised and immediately went to trailer schema and started parsing the trailer record, eventually, the parsing has ended up successfully.

Here, I am expecting an exception to be thrown in body the part as soon as the DFDL finds its exception when it wrongly parse the trailed record in the body schema and find the exception. Why it is not happening even though the discriminator works and parsed?

LOGS:

Nov 14, 2017, 8:14:31 PM info: Offset: 896. Attempting expression '{fn:exists(/EmployeeReports/Reports)}' for element 'Reports'.

Nov 14, 2017, 8:14:31 PM info: Offset: 896. A DFDL discriminator with condition '{fn:exists(/EmployeeReports/Reports)}' evaluated to true while parsing 'Reports'.
[dfdl = /MessageModelling/EmployeeReports.xsd, scd = #xscd(/schemaElement::EmployeeReports/type::0/model::sequence/schemaElement::Reports), 139]

-------------------------------------------

Nov 14, 2017, 8:14:31 PM info: Offset: 1042. Did not find terminator for 'Reports'. Expected terminator list is '%CR;%LF;'.
[dfdl = /MessageModelling/EmployeeReports.xsd, scd = #xscd(/schemaElement::EmployeeReports/type::0/model::sequence/schemaElement::Reports), 101]

Nov 14, 2017, 8:14:31 PM error: CTDP3042E: Terminator '%CR;%LF;' not found at offset '1,042' for element '/EmployeeReports[1]/Reports[13]'.

Nov 14, 2017, 8:14:31 PM info: Offset: 1042. Parser was unable to resolve data on the current branch and will evaluate the next available branch beginning at offset '970' owned by the 'sequence' group contained within element 'EmployeeReports'.
[dfdl = /MessageModelling/EmployeeReports.xsd, scd = #xscd(/schemaElement::EmployeeReports/type::0/model::sequence), 221]

Nov 14, 2017, 8:14:31 PM info: Offset: 970. Occurrence '13' of element 'Reports' was not found in the data. occursCountKind is 'implicit' so no more occurrences of this element will be expected.
[dfdl = /MessageModelling/EmployeeReports.xsd, scd = #xscd(/schemaElement::EmployeeReports/type::0/model::sequence/schemaElement::Reports), 172]


TEST2:

I parsed an invalid test file which has 1 header, 12 body and 1 trailer. There is a problem of length in the second record of the body. When the exception identified in the body, it does not even though the discriminator is presented. It travels to trailer part and still trying to map and throws an exception from there.

Why it is not still working? What am I missing here?


Should I have initiator in the trailer?

Please help me out.

vijragem wrote:
Can you give me an expression for discriminator that set that evaluates to true for the body.

timber wrote:
I was about to point out the same thing.

You need to add a discriminator that evaluates to true as soon as you know for sure that you are parsing a body record. That will prevent the parser from backing out and trying the alternative (the trailer). If the body record has a tag then your task is simple. If not, you may have to get creative.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Nov 14, 2017 5:04 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

The function shown is not really a discriminator.
To be a discriminator it would need to show a specific value like
if (/Employee/Reports/Report="Report")...
This identifies a value in the record that determines that the record is indeed a body record.

Just checking for the existence of a structure without any verification of its value cannot be considered to be a discriminator...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
vijragem
PostPosted: Wed Nov 15, 2017 2:30 am    Post subject: Reply with quote

Novice

Joined: 09 Jan 2015
Posts: 14

Thanks a lot.

Finally, it worked. I have added a discriminator in the record field to check the first field is not null. (it is just a dummy check). Any parser exception, all has been thrown from the schema where it failed.

Have a good Day!!!!!!!!!!!!!!!!!1

fjb_saper wrote:
The function shown is not really a discriminator.
To be a discriminator it would need to show a specific value like
if (/Employee/Reports/Report="Report")...
This identifies a value in the record that determines that the record is indeed a body record.

Just checking for the existence of a structure without any verification of its value cannot be considered to be a discriminator...
Back to top
View user's profile Send private message
timber
PostPosted: Wed Nov 15, 2017 4:34 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

Quote:
I have added a discriminator in the record field to check the first field is not null. (it is just a dummy check)
That sounds wrong. What happens if the input is a valid message? I assume that it will try to parse the Trailer as a Record, your discriminator will tell the parser that it's on the correct path and it will throw a fatal exception.

Sorry, but there is no shortcut here. You need to tell the DFDL parser how to distinguish between a Record and a Trailer. We don't know how to do that, because we have not seen an example of your input data. The DFDL parser doesn't know either, because...it's a just a parser.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » IIB9 - DFDL Parser - Expected exception is not occuring
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.