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 » Create new Object from XSD in ESQL

Post new topic  Reply to topic
 Create new Object from XSD in ESQL « View previous topic :: View next topic » 
Author Message
mrk.for.dev
PostPosted: Mon Jan 11, 2021 5:45 am    Post subject: Create new Object from XSD in ESQL Reply with quote

Novice

Joined: 11 Jan 2021
Posts: 23

Is there a way to create an object whose format is defined in a message model?

Actually, I have created a message model with some fields containing default values and some restrictions. I managed with the following code to create a message in ESQL, but the other fields (which contain default values) do not appear :

Code:
      CREATE LASTCHILD OF OutputRoot DOMAIN('DFDL');      
      -- SET OutputRoot.Properties = InputRoot.Properties;
      
      SET OutputRoot.Properties.MessageSet = '{ObjectsDefinitionLibrary}';
      SET OutputRoot.Properties.MessageType = '{}:Example1MsgModel';
      SET OutputRoot.DFDL.Example1MsgModel.record[1].FieldOne = 'Value1';


Will this be possible with ESQL?
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Jan 11, 2021 7:33 am    Post subject: Re: Create new Object from XSD in ESQL Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

mrk.for.dev wrote:
I managed with the following code to create a message in ESQL, but the other fields (which contain default values) do not appear :


Do not appear where? The DFDL defaults probably don't show up in a trace or the debugger because they're used as part of the serialization process. They should therefore show up in the final written record.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mrk.for.dev
PostPosted: Mon Jan 11, 2021 7:55 am    Post subject: Reply with quote

Novice

Joined: 11 Jan 2021
Posts: 23

The default fields are not visible either in the debugger or in the final output (to a file).
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Jan 11, 2021 8:11 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

mrk.for.dev wrote:
The default fields are not visible either in the debugger or in the final output (to a file).


Post your DFDL
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mrk.for.dev
PostPosted: Mon Jan 11, 2021 8:55 am    Post subject: Reply with quote

Novice

Joined: 11 Jan 2021
Posts: 23

Here is the DFDL :

Code:
<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:csv="http://www.ibm.com/dfdl/CommaSeparatedFormat" xmlns:dfdl="http://www.ogf.org/dfdl/dfdl-1.0/" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:ibmDfdlExtn="http://www.ibm.com/dfdl/extensions" xmlns:ibmSchExtn="http://www.ibm.com/schema/extensions">


    <xsd:import namespace="http://www.ibm.com/dfdl/CommaSeparatedFormat" schemaLocation="IBMdefined/CommaSeparatedFormat.xsd"/>
    <xsd:annotation>
      <xsd:appinfo source="http://www.ogf.org/dfdl/">
         <dfdl:format documentFinalTerminatorCanBeMissing="yes" encoding="{$dfdl:encoding}" escapeSchemeRef="csv:CSVEscapeScheme" ref="csv:CommaSeparatedFormat"/>
      </xsd:appinfo>
   </xsd:annotation>


   <xsd:element ibmSchExtn:docRoot="true" name="Example1MsgModel">
      <xsd:complexType>
         <xsd:sequence dfdl:separator="">
            <xsd:element dfdl:terminator="%CR;%LF;%WSP*;" name="record">
               <xsd:complexType>
                  <xsd:sequence dfdl:separator="|" dfdl:separatorSuppressionPolicy="trailingEmpty">
                     
                     <xsd:element ibmDfdlExtn:sampleValue="value1" minOccurs="0" name="FieldOne" type="xsd:string"/>
                     <xsd:element default="FIXED_VALUE" ibmDfdlExtn:sampleValue="value2" minOccurs="0" name="FieldTwo" type="xsd:string"/>
                                                                                                                                                                                                                                                                                                                                                
                        </xsd:sequence>
               </xsd:complexType>
            </xsd:element>            
         </xsd:sequence>
      </xsd:complexType>
   </xsd:element>


</xsd:schema>
[/code]


Here is the ESQL :

Code:
CREATE LASTCHILD OF OutputRoot DOMAIN('DFDL');      
      
      SET OutputRoot.Properties.MessageSet = '{ObjectsDefinitionLibrary}';
      SET OutputRoot.Properties.MessageType = '{}:Example1MsgModel';
      SET OutputRoot.DFDL.Example1MsgModel.record[1].FieldOne = 'AFFL02';
      
      DECLARE refInput REFERENCE TO InputRoot.DFDL.Exemple1EntrantMsg.record[1];
      DECLARE refOutput REFERENCE TO OutputRoot.DFDL.Example1MsgModel.record[1];   
      
      -- field 1
      SET refOutput.FieldOne = 'AFFL02';
Back to top
View user's profile Send private message
Vitor
PostPosted: Mon Jan 11, 2021 12:19 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

The elements are set to minOccurs=0, so if no value is provided to the model it doesn't serialize the element and is content it has done right.

If you set minOccurs=1 (indicating that the element must be present in the serialized file) and don't provide a value, then the model will ensure you get the element you insisted on by using a default.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
timber
PostPosted: Mon Jan 11, 2021 3:54 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1290

Quote:
Is there a way to create an object whose format is defined in a message model
You need to define what you mean by 'object'. Do you want to create a message tree based on the model? Or do you want to generate a valid BLOB from the model?

As has been said by others, if you want to generate a BLOB from a DFDL model, you must ensure that everything in the message model (including complex elements) has minOccurs>=1, and you must provide a default value for every field.
If you want a message tree, you will need to parse that BLOB using the DFDL parser. Which leads nicely into the answer to your other question...
Quote:
Will this be possible with ESQL?
ESQL does not offer a special statement to create a message tree from a model. However, it does offer two functions for parsing and writing any BLOB/message tree. Look up the ASBITSTREAM function, and the CREATE function (with the PARSE clause).
Back to top
View user's profile Send private message
mrk.for.dev
PostPosted: Tue Jan 12, 2021 12:16 am    Post subject: Reply with quote

Novice

Joined: 11 Jan 2021
Posts: 23

Indeed, when minOccurs is set to 1, the values reappear in the output file (not in the debugger).

The original goal was to replace the Mapping node by a Compute node that transforms a Message Model to a different one. With the Mapping node it is obvious, but with the Compute node you have to create this message from the Message Model with ESQL.

Thank you
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Jan 12, 2021 6:20 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

mrk.for.dev wrote:
Indeed, when minOccurs is set to 1, the values reappear in the output file (not in the debugger).


Because it's not until you actually ask the model to be serialized the lack of the element is a problem. That minOccurs=1 doesn't apply to the message tree (for good and sufficient reason)
_________________
Honesty is the best policy.
Insanity is the best defence.
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 » Create new Object from XSD in ESQL
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.