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 » Problem with <a xsi:nil="true"/> on parsing

Post new topic  Reply to topic
 Problem with <a xsi:nil="true"/> on parsing « View previous topic :: View next topic » 
Author Message
urufberg
PostPosted: Fri Nov 09, 2018 5:56 am    Post subject: Problem with <a xsi:nil="true"/> on parsing Reply with quote

Apprentice

Joined: 08 Sep 2017
Posts: 28

So, long story short, I have a provider that published a wsdl allowing elements to come in the nil form (<elementName xsi:nil="true"/>).
So the problem begins when I try to transform those elements to a JSON structure using a mapping node. Since the XMLNSC parser generates a child node with the NULL value, when the mapping node tries to perform the operation it results in an error making the JSON structure involved empty.

I've done a lot of reading regarding this (in this forum and in ibm kc) but I'm not able to come up with an elegant solution.

Should I switch to a compute node and perform a check for every nillable element (even specifying a condition with xpath functions as described in the documentation doesn't work)?

Is there a way to 'make the parser' understand this nil elements as an empty element? (like <elementName\>)

Any ideas would be appreciated.

PD. For context we are running our broker on IIB v10 fixpack 11
Back to top
View user's profile Send private message
timber
PostPosted: Fri Nov 09, 2018 7:07 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

Quote:
So the problem begins when I try to transform those elements to a JSON structure using a mapping node. Since the XMLNSC parser generates a child node with the NULL value, when the mapping node tries to perform the operation it results in an error making the JSON structure involved empty.
English is an awful language for describing programming problems. Please supply the input XML and the required output JSON for all scenarios. For bonus points, use [ code ] tags to make the snippets readable.

The mapping node does not know how to read the ESQL value NULL because it accesses the message tree using a DOM API. DOM has no concept of NULL. It detects a 'null' value by the presence of a child attribute xsi:nil with boolean value 'true' (in other words, it follows the XML convention).

Quote:
even specifying a condition with xpath functions as described in the documentation doesn't work
Described where? (please quote the URL)
What happened when you tried to do what the documentation said?
Back to top
View user's profile Send private message
urufberg
PostPosted: Fri Nov 09, 2018 11:22 am    Post subject: Reply with quote

Apprentice

Joined: 08 Sep 2017
Posts: 28

Hi timber, thank you for the quick answer. Sorry about the description, I'll try to be as descriptive as possible this time.
The issue is that the web service provider has his elements defined like this:

Code:
<xsd:element minOccurs="0" name="elementName" nillable="true" type="xsd:type"/>


So when I tryied to transform the xml data to JSON in a Mapping node, the result had empty arrays. When I debugged, what I saw is that the XMLNSC parser creates a node with a child nilled when the element is nill in the xml like this:

Code:
<elementName xsi:nil="true"/>



See for example "FechaNacimiento" in this debug trace:



After a bunch of reading I came up with using XLST Transform to take out from the body elements with the xsi:nil="true" flag. Here is the code:

Code:
 <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  exclude-result-prefixes = "NS1">

  <xsl:output omit-xml-declaration="yes" indent="yes"/>
  <xsl:strip-space elements="*"/>

  <!-- TEMPLATE #1 -->
  <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
  </xsl:template>

  <!-- TEMPLATE #2 -->
  <xsl:template match="*[@xsi:nil = 'true']" />
</xsl:stylesheet>


So after the XLST Transform I end up getting what I want but with a small problem, the NS1 (namespace used in the soap request) is passed as part of the body:



Now when I apply the transformation with the mapping node this is what I get:



As you can see the JSON arrays are empty. For some reason I still don't get the expected outcome and I'm suspicious about that namespace remaining there.
Just for more insight here is what the mapping node looks like: ('For each' tranformations have a bunch of move, converts, etc)




About your question:
Quote:
Described where? (please quote the URL)

I used the conditionals described here with no luck. I expected nillable to work but it didn't. Also didn't seem as a good solution check for every single nillable element

So that's all the information I have for now, maybe you can throw some ligh into the darkness.

Thank you in advance
Back to top
View user's profile Send private message
timber
PostPosted: Mon Nov 12, 2018 1:57 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

Thanks. Much clearer now.

No surprise that XMLNSC creates the xsi:nil attributes in the message tree. They are there in the input XML, so it would be strange if it didn't put them inot the message tree.

You are trying to map the value of some simple elements into the output. If you were using ESQL, you could use this syntax
Code:
SET myOutputRef VALUE = FIELDVALUE(myInputRef);
to ensure that the simple value is copied but the child elements are not.

In the Mapping node, I suspect that there is probably a similar trick that you can use. Probably a custom XSLT function that will take the value of the node. Maybe martin_b will be along to help with that part of the problem...
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 » Problem with <a xsi:nil="true"/> on parsing
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.