Author |
Message
|
TKIY |
Posted: Wed Nov 21, 2018 6:09 am Post subject: Converting DFDL fragment to BLOB |
|
|
Novice
Joined: 23 Aug 2016 Posts: 19
|
I have a somewhat complex DFDL created that contains a set of repeating records. I have the requirement to separate each of these records and place them, individually, into text files.
Using ASBITSTREAM converts the DFDL to BLOB as expected but each file created has the entire DFDL structure, not the specific elements selected.
This is what I am working with right now:
Code: |
DECLARE ackStream BLOB ASBITSTREAM(InputRoot.DFDL.ns:Group[counter] CCSID InputRoot.Properties.CodedCharSetId ENCODING InputRoot.Properties.Encoding);
SET OutputRoot.BLOB.BLOB = ackStream ; |
The output, however includes the whole structure, not the specific instance of the 'Group' element as I would expect.
Any hints? |
|
Back to top |
|
 |
rekarm01 |
Posted: Wed Nov 21, 2018 10:39 am Post subject: Re: Converting DFDL fragment to BLOB |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
TKIY wrote: |
The output, however includes the whole structure, not the specific instance of the 'Group' element as I would expect. |
The DFDL parser doesn't support a FolderBitStream option, but one alternative is to create a separate DFDL schema for ASBITSTREAM(), describing just the 'Group' sub-tree. |
|
Back to top |
|
 |
TKIY |
Posted: Wed Nov 21, 2018 10:58 am Post subject: Re: Converting DFDL fragment to BLOB |
|
|
Novice
Joined: 23 Aug 2016 Posts: 19
|
rekarm01 wrote: |
TKIY wrote: |
The output, however includes the whole structure, not the specific instance of the 'Group' element as I would expect. |
The DFDL parser doesn't support a FolderBitStream option, but one alternative is to create a separate DFDL schema for ASBITSTREAM(), describing just the 'Group' sub-tree. |
Right, makes sense. I'll give that a shot. |
|
Back to top |
|
 |
rekarm01 |
Posted: Wed Nov 21, 2018 2:28 pm Post subject: Re: Converting DFDL fragment to BLOB |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
Another alternative that wouldn't require a separate schema is to define 'Group' as a global element, and indicate the desired model and message, either in the Properties header, or in the ASBITSTREAM() SET/TYPE clauses, as needed. |
|
Back to top |
|
 |
timber |
Posted: Fri Nov 23, 2018 5:11 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Quote: |
Another alternative that wouldn't require a separate schema is to define 'Group' as a global element, and indicate the desired model and message, either in the Properties header, or in the ASBITSTREAM() SET/TYPE clauses, as needed. |
I was just about to say the same thing. But you should create a message definition from that global element - otherwise the DFDL parser might not recognise it as a valid starting point for a message. |
|
Back to top |
|
 |
TKIY |
Posted: Mon Nov 26, 2018 5:41 am Post subject: |
|
|
Novice
Joined: 23 Aug 2016 Posts: 19
|
Creating the dedicated message worked from the perspective of copying a single instance to a new message, but ASBITSTREAM is having trouble serializing it. One problem down, one more added on to the pile.
Thanks for the help! |
|
Back to top |
|
 |
TKIY |
Posted: Thu Nov 29, 2018 10:20 am Post subject: |
|
|
Novice
Joined: 23 Aug 2016 Posts: 19
|
Just wanted to say I got this fully working finally. Many thanks @rekarm01 and @timber. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Nov 29, 2018 12:44 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
TKIY wrote: |
Just wanted to say I got this fully working finally. |
Care to share your solution for the benefit of future readers? And, obviously, well done. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
TKIY |
Posted: Fri Nov 30, 2018 5:33 am Post subject: |
|
|
Novice
Joined: 23 Aug 2016 Posts: 19
|
Resolved the ASBITSTREAM issue after I realized that the initial element I was creating in the output root was incorrect. I was creating the first element within the 'Group' subtree without creating the subtree first.
Creating a message which contained only the 'Group' subtree and using ASBITSTREAM was the correct solution.
Code: |
CREATE LASTCHILD OF OutputLocalEnvironment.Variables DOMAIN 'DFDL' ;
SET OutputLocalEnvironment.Variables.DFDL.ns:GROUP_MSG.ns:"GROUP" = InputRoot.DFDL.ns:MAIN_MESSAGE.ns:SUBTREE.ns:"GROUP"[counter] ;
DECLARE ackStream BLOB;
SET ackStream = CAST(ASBITSTREAM(OutputLocalEnvironment.Variables.DFDL.ns:GROUP_MSG) AS BLOB CCSID 819);
SET OutputRoot.BLOB.BLOB = ackStream ; |
|
|
Back to top |
|
 |
rekarm01 |
Posted: Mon Dec 03, 2018 6:14 pm Post subject: Re: Converting DFDL fragment to BLOB |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
TKIY wrote: |
Code: |
... CAST(ASBITSTREAM(OutputLocalEnvironment.Variables.DFDL.ns:GROUP_MSG) AS BLOB CCSID 819) ... |
|
CAST(BLOB AS BLOB) is unnecessary here; it has no effect because ASBITSTREAM() already returns a BLOB. Also, CAST() does not use the CCSID parameter unless converting to/from CHARACTER. |
|
Back to top |
|
 |
TKIY |
Posted: Tue Dec 04, 2018 6:20 am Post subject: Re: Converting DFDL fragment to BLOB |
|
|
Novice
Joined: 23 Aug 2016 Posts: 19
|
rekarm01 wrote: |
TKIY wrote: |
Code: |
... CAST(ASBITSTREAM(OutputLocalEnvironment.Variables.DFDL.ns:GROUP_MSG) AS BLOB CCSID 819) ... |
|
CAST(BLOB AS BLOB) is unnecessary here; it has no effect because ASBITSTREAM() already returns a BLOB. Also, CAST() does not use the CCSID parameter unless converting to/from CHARACTER. |
Good to know, I'll clean that up. |
|
Back to top |
|
 |
|