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 » Mapping multiple xml tags with Mapping Node

Post new topic  Reply to topic Goto page 1, 2  Next
 Mapping multiple xml tags with Mapping Node « View previous topic :: View next topic » 
Author Message
nelson
PostPosted: Thu May 30, 2013 2:31 pm    Post subject: Mapping multiple xml tags with Mapping Node Reply with quote

Partisan

Joined: 02 Oct 2012
Posts: 313

Hi,

I'm using WMB 8.0.0.1

My question is, the Mapping Node is able to do the following transformation?

Input: XMLNSC Domain

Code:
<data>
   <a id="1">data1</a>
   <a id="2">data2</a>
   ...
   <a id="n">datan</a>
</data>


Output: DFDL Domain

Code:
data3data2datan


The <a></a> tag may appear many times. The problem that I'm facing is that in the mapping node the structure only shows one "a" (the cardinality of the element is [0..*])and I don't know how to dynamically choose which tag to map with an specific field depending on the id attribute. I have tried using the if function, but didn't work.

Something like this is the Mapping Node transformation

XMLNSC DFDL

data
a
id
<mydata> ------------> field1
field2
field3

I know that this can be done with ESQL, but I was wondering if it is possible within the mapping node.

Thanks in advance.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu May 30, 2013 2:35 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

draw a line from the repeating structure on the input side to a repeating structure on the output side.

This will create a for block.
Back to top
View user's profile Send private message
nelson
PostPosted: Thu May 30, 2013 2:47 pm    Post subject: Reply with quote

Partisan

Joined: 02 Oct 2012
Posts: 313

mqjeff wrote:
draw a line from the repeating structure on the input side to a repeating structure on the output side.

This will create a for block.


Thanks mqjeff. The problem here is that the input has a repeating structure, but the output does not. The same "a" input "tag" can fill many statics fields in the output side? In other words, your solution, but choosing which output fields to fill, depending on the value of an attribute of the "a" tag.

Thanks again!
Back to top
View user's profile Send private message
mqjeff
PostPosted: Thu May 30, 2013 2:51 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

create a for block.

Inside the for block, draw many lines from the input to the output message, each one an IF clause.
Back to top
View user's profile Send private message
nelson
PostPosted: Fri May 31, 2013 8:42 am    Post subject: Reply with quote

Partisan

Joined: 02 Oct 2012
Posts: 313

mqjeff wrote:
create a for block.

Inside the for block, draw many lines from the input to the output message, each one an IF clause.


I did a little experiment. I have created a for each block, validate an attribute of the repeating structure and depending on that value set field1 or field2 of a non repeating structure. After the iterations the two fields are supposed to be with the respective values?

I'm getting this exception:

Code:
ExceptionList: ( ['MQROOT' : 0x113f31c0]
  (0x01000000:Name):RecoverableException = (
    (0x03000000:NameValue):File                 = 'F:\build\S000_P\src\DataFlowEngine\ImbDataFlowNode.cpp' (CHARACTER)
    (0x03000000:NameValue):Line                 = 1129 (INTEGER)
    (0x03000000:NameValue):Function             = 'ImbDataFlowNode::createExceptionList' (CHARACTER)
    (0x03000000:NameValue):Type                 = 'ComIbmMSLMappingNode' (CHARACTER)
    (0x03000000:NameValue):Name                 = 'gbm/demo/Servicio1#FCMComposite_1_18' (CHARACTER)
    (0x03000000:NameValue):Label                = 'gbm.demo.Servicio1.eRRML -> CFW' (CHARACTER)
    (0x03000000:NameValue):Catalog              = 'BIPmsgs' (CHARACTER)
    (0x03000000:NameValue):Severity             = 3 (INTEGER)
    (0x03000000:NameValue):Number               = 2230 (INTEGER)
    (0x03000000:NameValue):Text                 = 'Node throwing exception' (CHARACTER)
    (0x01000000:Name     ):RecoverableException = (
      (0x03000000:NameValue):File                 = 'MbErrorHandler.java' (CHARACTER)
      (0x03000000:NameValue):Line                 = 146 (INTEGER)
      (0x03000000:NameValue):Function             = 'evaluate' (CHARACTER)
      (0x03000000:NameValue):Type                 = '' (CHARACTER)
      (0x03000000:NameValue):Name                 = '' (CHARACTER)
      (0x03000000:NameValue):Label                = '' (CHARACTER)
      (0x03000000:NameValue):Catalog              = 'BIPmsgs' (CHARACTER)
      (0x03000000:NameValue):Severity             = 3 (INTEGER)
      (0x03000000:NameValue):Number               = 3947 (INTEGER)
      (0x03000000:NameValue):Text                 = 'Caught BrokerXCIDynamicException' (CHARACTER)
      (0x01000000:Name     ):Insert               = (
        (0x03000000:NameValue):Type = 5 (INTEGER)
        (0x03000000:NameValue):Text = '{gbm.demo}:Servicio1_eRRML____CFW' (CHARACTER)
      )
      (0x01000000:Name     ):Insert               = (
        (0x03000000:NameValue):Type = 5 (INTEGER)
        (0x03000000:NameValue):Text = 'java.lang.RuntimeException: Use of default: in switch() is unexpected.' (CHARACTER)
      )
      (0x01000000:Name     ):RecoverableException = (
        (0x03000000:NameValue):File     = 'MbErrorHandler.java' (CHARACTER)
        (0x03000000:NameValue):Line     = 310 (INTEGER)
        (0x03000000:NameValue):Function = 'throwableToMbException' (CHARACTER)
        (0x03000000:NameValue):Type     = '' (CHARACTER)
        (0x03000000:NameValue):Name     = '' (CHARACTER)
        (0x03000000:NameValue):Label    = '' (CHARACTER)
        (0x03000000:NameValue):Catalog  = 'BIPmsgs' (CHARACTER)
        (0x03000000:NameValue):Severity = 3 (INTEGER)
        (0x03000000:NameValue):Number   = 3949 (INTEGER)
        (0x03000000:NameValue):Text     = 'Caught BrokerXCIDynamicException' (CHARACTER)
        (0x01000000:Name     ):Insert   = (
          (0x03000000:NameValue):Type = 5 (INTEGER)
          (0x03000000:NameValue):Text = 'Use of default: in switch() is unexpected.

' (CHARACTER)
        )
      )
    )
  )
)


Any clue to solve the problem?

Thanks a lot.
Back to top
View user's profile Send private message
kunal07
PostPosted: Sat Jun 01, 2013 9:03 am    Post subject: Reply with quote

Acolyte

Joined: 05 Dec 2012
Posts: 72

I also having the same requirement, want to concat multiple xml tags from source to a single tag in output. i tried to use custom code but no able to add the esql files.
Back to top
View user's profile Send private message
nelson
PostPosted: Mon Jun 03, 2013 8:50 am    Post subject: Reply with quote

Partisan

Joined: 02 Oct 2012
Posts: 313

I took a different way: use a Custom XPath expression, but the same error happens!

If this helps, I'm using the following XML schema:

Code:

...
<xs:element name="Parameters">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="Input"/>
        <xs:element ref="Output"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="Input">
      <xs:complexType>
      <xs:sequence>
        <xs:element ref="Param" maxOccurs="unbounded" minOccurs="0"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

...
 
  <xs:element name="Param">
    <xs:complexType>
      <xs:attribute name="compels" use="required"/>
      <xs:attribute name="length" use="required"/>
      <xs:attribute name="mime" use="required"/>
      <xs:attribute name="name" use="required"/>
      <xs:attribute name="nullable" use="required"/>
      <xs:attribute name="type" use="required"/>
    </xs:complexType>
  </xs:element>
...


In the mapping node I drag an arrow from "Input" to the field "cuenta" and use a Custom XPath expression to do the mapping:

Code:
$Input/Param[@name='cuenta']/value


Unfortunately when I run the flow it throws the following error, that seems to be the same error when I was using the other approach:

mqjeff wrote:
create a for block.

Inside the for block, draw many lines from the input to the output message, each one an IF clause.


A for each block and if sentences to dynamically map the repeating tag to the target field (non repeating field).

The exception is:

Code:
ExceptionList: ( ['MQROOT' : 0x147e95f0]
  (0x01000000:Name):RecoverableException = (
    (0x03000000:NameValue):File                 = 'F:\build\S000_P\src\DataFlowEngine\ImbDataFlowNode.cpp' (CHARACTER)
    (0x03000000:NameValue):Line                 = 1129 (INTEGER)
    (0x03000000:NameValue):Function             = 'ImbDataFlowNode::createExceptionList' (CHARACTER)
    (0x03000000:NameValue):Type                 = 'ComIbmMSLMappingNode' (CHARACTER)
    (0x03000000:NameValue):Name                 = 'gbm/demo/Servicio1#FCMComposite_1_18' (CHARACTER)
    (0x03000000:NameValue):Label                = 'gbm.demo.Servicio1.eRRML -> CFW' (CHARACTER)
    (0x03000000:NameValue):Catalog              = 'BIPmsgs' (CHARACTER)
    (0x03000000:NameValue):Severity             = 3 (INTEGER)
    (0x03000000:NameValue):Number               = 2230 (INTEGER)
    (0x03000000:NameValue):Text                 = 'Node throwing exception' (CHARACTER)
    (0x01000000:Name     ):RecoverableException = (
      (0x03000000:NameValue):File                 = 'MbErrorHandler.java' (CHARACTER)
      (0x03000000:NameValue):Line                 = 146 (INTEGER)
      (0x03000000:NameValue):Function             = 'evaluate' (CHARACTER)
      (0x03000000:NameValue):Type                 = '' (CHARACTER)
      (0x03000000:NameValue):Name                 = '' (CHARACTER)
      (0x03000000:NameValue):Label                = '' (CHARACTER)
      (0x03000000:NameValue):Catalog              = 'BIPmsgs' (CHARACTER)
      (0x03000000:NameValue):Severity             = 3 (INTEGER)
      (0x03000000:NameValue):Number               = 3947 (INTEGER)
      (0x03000000:NameValue):Text                 = 'Caught BrokerXCIDynamicException' (CHARACTER)
      (0x01000000:Name     ):Insert               = (
        (0x03000000:NameValue):Type = 5 (INTEGER)
        (0x03000000:NameValue):Text = '{default}:Servicio1_eRRML____CFW2' (CHARACTER)
      )
      (0x01000000:Name     ):Insert               = (
        (0x03000000:NameValue):Type = 5 (INTEGER)
        (0x03000000:NameValue):Text = 'java.lang.RuntimeException: Use of default: in switch() is unexpected.' (CHARACTER)
      )
      (0x01000000:Name     ):RecoverableException = (
        (0x03000000:NameValue):File     = 'MbErrorHandler.java' (CHARACTER)
        (0x03000000:NameValue):Line     = 310 (INTEGER)
        (0x03000000:NameValue):Function = 'throwableToMbException' (CHARACTER)
        (0x03000000:NameValue):Type     = '' (CHARACTER)
        (0x03000000:NameValue):Name     = '' (CHARACTER)
        (0x03000000:NameValue):Label    = '' (CHARACTER)
        (0x03000000:NameValue):Catalog  = 'BIPmsgs' (CHARACTER)
        (0x03000000:NameValue):Severity = 3 (INTEGER)
        (0x03000000:NameValue):Number   = 3949 (INTEGER)
        (0x03000000:NameValue):Text     = 'Caught BrokerXCIDynamicException' (CHARACTER)
        (0x01000000:Name     ):Insert   = (
          (0x03000000:NameValue):Type = 5 (INTEGER)
          (0x03000000:NameValue):Text = 'Use of default: in switch() is unexpected.

' (CHARACTER)
        )
      )
    )
  )
)



I have tried many combinations, for example using the repeating structure as the source field of the transformation, but get the same error. In this case I'm using the parent of the repeating tag...

Maybe... there is some limitation of the mapping node on this issue (repeating to non repeating structure) that I'm not taking care of?

If I tell the XPath expression the specific index of the array it works!

Code:
$Input/Param[1]/value


But this does not work for our purposes..

Thanks in advance for any help.
Back to top
View user's profile Send private message
martinb
PostPosted: Wed Jan 29, 2014 4:56 am    Post subject: Reply with quote

Master

Joined: 09 Nov 2006
Posts: 210
Location: UK

Was searching something else and noticed this thread which does not look to have been answered.

Depending on the the requirements there are two approaches to consider here

(1) fn:string-join function concatenates a sequence of strings

So in the original question, using fn:string-join from the repeating "a" element to the singleton target field would concatenate all the input values

(2) If you need to pick a filtered set of child elements from a repeating complex structure depending on some value of another child, you would need to apply a XPath predicate. A predicate will again yeild a sequence of values, so you would need to ensure that is handled

For example you could use a Custom Xpath transform to select the set of "a" elements from a parent "p" that has another child "b" with value > 10, and concatenate those into a single target via

fn:string-join( p[b > 10]a , '' )
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Jan 29, 2014 6:39 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Not sure how I managed to miss this post the first time around...maybe my trip to Yorkshire distracted me...

@nelson: Nobody has suggested the most obvious solution yet. You are using the DFDL domain to write this message. Instead of concatenating the values using various tricks in the Mapping node, why not let the DFDL parser handle it? Your output *does* have a repeating element - you just didn't think of it that way because you were focused on doing the concatenation in the map.

My solution would be
- define the output element as a complex element containing sub-elements 'data' and 'id'.
- Design the map to copy the input elements into the repeating output element.
- set the DFDL properties on the sequence group and the sub-elements to get the correct formatting.
Let me know if you need assistance with this.
_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Jan 29, 2014 6:47 am    Post subject: Reply with quote

Grand High Poobah

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

kimbert wrote:
Not sure how I managed to miss this post the first time around...maybe my trip to Yorkshire distracted me...


Savaged by a whippit? Had a flat cap pulled over your eyes?
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
dogorsy
PostPosted: Wed Jan 29, 2014 7:06 am    Post subject: Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

Vitor wrote:
kimbert wrote:
Not sure how I managed to miss this post the first time around...maybe my trip to Yorkshire distracted me...


Savaged by a whippit? Had a flat cap pulled over your eyes?

Or maybe sometimes it is nice to sit back and see the answers the 'experts' give ? !!
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Jan 29, 2014 7:07 am    Post subject: Reply with quote

Grand High Poobah

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

dogorsy wrote:
Vitor wrote:
kimbert wrote:
Not sure how I managed to miss this post the first time around...maybe my trip to Yorkshire distracted me...


Savaged by a whippit? Had a flat cap pulled over your eyes?

Or maybe sometimes it is nice to sit back and see the answers the 'experts' give ? !!


@kimbert is the God Of Parsing
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
dogorsy
PostPosted: Wed Jan 29, 2014 7:13 am    Post subject: Reply with quote

Knight

Joined: 13 Mar 2013
Posts: 553
Location: Home Office

Vitor wrote:
dogorsy wrote:
Vitor wrote:
kimbert wrote:
Not sure how I managed to miss this post the first time around...maybe my trip to Yorkshire distracted me...


Savaged by a whippit? Had a flat cap pulled over your eyes?

Or maybe sometimes it is nice to sit back and see the answers the 'experts' give ? !!


@kimbert is the God Of Parsing

hmm... agree that kimbert is good, however, this problem is with serializing (or mapping ) and not parsing.
Back to top
View user's profile Send private message
kimbert
PostPosted: Wed Jan 29, 2014 7:22 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Had I been savaged by any type of beast, it would have been a correctly-spelled one, old chap!

@dogorsy: You're good at pedantry, but not as good as me. You have to be really annoying to claim mastery
_________________
Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Jan 29, 2014 7:25 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

kimbert wrote:
Had I been savaged by any type of beast, it would have been a correctly-spelled one, old chap!

@dogorsy: You're good at pedantry, but not as good as me. You have to be really annoying to claim mastery


I'm wondering how much more bait we need before shanson pops in.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Mapping multiple xml tags with Mapping Node
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.