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 » IIB Mapping node and default values for missing input fields

Post new topic  Reply to topic
 IIB Mapping node and default values for missing input fields « View previous topic :: View next topic » 
Author Message
Muhammad Haider
PostPosted: Sun Oct 30, 2016 3:17 am    Post subject: IIB Mapping node and default values for missing input fields Reply with quote

Apprentice

Joined: 14 Mar 2011
Posts: 43

We have defined our message models by selecting: 'New message model' >> 'Create an empty xml schema file, i will model my data using the xml schema editor'

E.g., consider following model xml in xsd file:

<?xml version="1.0" encoding="UTF-8"?><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:complexType name="Type1">
<xsd:sequence>
<xsd:element name="member1" type="xsd:string" default="mem1"></xsd:element>
<xsd:element name="member2" type="xsd:string" default="mem2"></xsd:element>
<xsd:element name="member3" type="xsd:string" default="mem3" minOccurs="1" ></xsd:element>
</xsd:sequence>
</xsd:complexType>

<xsd:element name="type1obj" type="Type1"></xsd:element>
</xsd:schema>

Now I give following input to my IIB flow using a MQ node
<type1obj><member1>m1</member1><member2/></type1obj>

I have a mapping node which copies type1obj object from input to type1obj in output, hence i get following output from mapping node:
<type1obj><member1>m1</member1><member2/></type1obj>

But I want to get all elements in my output xml whether they were present in input or not. Missing elements in input should have their default values as defined in model, so i want an output like:

<type1obj><member1>m1</member1><member2>mem2</member2><member3>mem3</member3></type1obj>

How can this be achieved using mapping node ?
Back to top
View user's profile Send private message
timber
PostPosted: Sun Oct 30, 2016 1:51 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1292

The Mapping node does not parse your input XML, and it does not apply default values that are specified in your xsd. It simply maps one message tree to another message tree.

The XMLNSC parser parses the input XML. It is a standard XML parser, so it will apply xsd default values in the same way as any other XML parser. The XML specification says that default values for an element are applied when the element is 'present and empty'. So your example
Code:
<type1obj><member1>m1</member1><member2/></type1obj>
should produce this message tree
Code:
type1obj
    member1=m1
    member2=mem2
Note that member3 is not in the input message tree because the tag was missing. Missing tags do not get default values. This is an XML Schema rule, not an IIB rule.

btw, before somebody asks, this input XML:
Code:
<type1obj><member1>m1</member1><member2></member2></type1obj>
...means exactly the same as the XML above and should always produce the same results in any XML processing system.
Back to top
View user's profile Send private message
Muhammad Haider
PostPosted: Sun Oct 30, 2016 8:06 pm    Post subject: Reply with quote

Apprentice

Joined: 14 Mar 2011
Posts: 43

@timber

Excellent explanation, Thanks

I tested this, and just to add to your reply, when we use xmlnsc parsing and xsd models then we need to use: Build tree using XML schema data types (check this option in Parser Options) plus Validate (content and value) property in validation tag. This will then apply the default values from xsd and also apply any checks that are specified in xsd.
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 » IIB Mapping node and default values for missing input fields
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.