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 » Sorting in Message Broker using XSL

Post new topic  Reply to topic Goto page 1, 2  Next
 Sorting in Message Broker using XSL « View previous topic :: View next topic » 
Author Message
Simbu
PostPosted: Fri Jul 26, 2013 1:35 am    Post subject: Sorting in Message Broker using XSL Reply with quote

Master

Joined: 17 Jun 2011
Posts: 289
Location: Tamil Nadu, India

Hi All,

My requirement is to sort multiple elements in the repeating complex elements in message broker and finally send all records in a file in fixed format to destination system.

My Input XML is as below

Code:
<Items>
   <ItemLoc>
      <location>5</location>
      <class>2</class>
      <item>2</item>
   </ItemLoc>
   <ItemLoc>
         <location>5</location>
         <class>1</class>
         <item>1</item>         
   </ItemLoc>
   <ItemLoc>
         <location>2</location>
         <class>6</class>
         <item>10</item>         
   </ItemLoc>
   <ItemLoc>
         <location>2</location>
         <class>7</class>
         <item>11</item>         
   </ItemLoc>
   <ItemLoc>
         <location>2</location>
         <class>7</class>
         <item>5</item>         
   </ItemLoc>
</Items>


First I need to sort all the records based on the location in ItemLoc and with location as a reference, I need to sort by class under each same location and finally sort the items under same class and finally my Output XML should be like below

Code:
<Items>
   <ItemLoc>
      <location>2</location>
      <class>6</class>
      <item>10</item>
   </ItemLoc>
   <ItemLoc>
         <location>2</location>
         <class>7</class>
         <item>5</item>         
   </ItemLoc>
   <ItemLoc>
         <location>2</location>
         <class>7</class>
         <item>11</item>         
   </ItemLoc>
   <ItemLoc>
         <location>5</location>
         <class>1</class>
         <item>1</item>         
   </ItemLoc>
   <ItemLoc>
         <location>5</location>
         <class>2</class>
         <item>2</item>         
   </ItemLoc>
</Items>   


I tried with XSL to do this sorting and it is working fine

Code:

      <Items>
         <xsl:for-each select="Items/ItemLoc">
            <xsl:sort select="location" data-type="number"/>
            <xsl:sort select="class" data-type="number"/>
            <xsl:sort select="item" data-type="number"/>
            <xsl:copy-of select="." />
         </xsl:for-each>
      </Items>



My Broker and Toolkit version is 8.0.0.2 running on windows

Please share your comments on whether using XSL is best approach for Sorting or not in message broker.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Jul 26, 2013 2:07 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

It's easy enough to write an insertion sort in ESQL to build the output tree in sorted order.

It's twice as easy to use the sorting facilities in the Graphical Data Mapper in v8 and later.
Back to top
View user's profile Send private message
Simbu
PostPosted: Fri Jul 26, 2013 8:36 am    Post subject: Reply with quote

Master

Joined: 17 Jun 2011
Posts: 289
Location: Tamil Nadu, India

Thanks for the suggestion. Can you please show some lights on how to use Graphical Data Mapper for sorting.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Fri Jul 26, 2013 9:21 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

Simbu wrote:
Thanks for the suggestion. Can you please show some lights on how to use Graphical Data Mapper for sorting.


http://publib.boulder.ibm.com/infocenter/wmbhelp/v8r0m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Fcm28851_.htm

Quote:
Sorts the mapping objects so that the appearance of transforms are prioritized by the source. && Sorts the mapping object so that the appearance of transforms are prioritized by the target.

_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Fri Jul 26, 2013 9:56 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

lancelotlinc wrote:
Simbu wrote:
Thanks for the suggestion. Can you please show some lights on how to use Graphical Data Mapper for sorting.


http://publib.boulder.ibm.com/infocenter/wmbhelp/v8r0m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Fcm28851_.htm

Quote:
Sorts the mapping objects so that the appearance of transforms are prioritized by the source. && Sorts the mapping object so that the appearance of transforms are prioritized by the target.


Actually I think I meant the "order" property
http://publib.boulder.ibm.com/infocenter/wmbhelp/v8r0m0/topic/com.ibm.etools.mft.doc/cm28858_.htm
Back to top
View user's profile Send private message
Simbu
PostPosted: Sat Jul 27, 2013 2:33 am    Post subject: Reply with quote

Master

Joined: 17 Jun 2011
Posts: 289
Location: Tamil Nadu, India

mqjeff wrote:
lancelotlinc wrote:
Simbu wrote:
Thanks for the suggestion. Can you please show some lights on how to use Graphical Data Mapper for sorting.


http://publib.boulder.ibm.com/infocenter/wmbhelp/v8r0m0/index.jsp?topic=%2Fcom.ibm.etools.mft.doc%2Fcm28851_.htm

Quote:
Sorts the mapping objects so that the appearance of transforms are prioritized by the source. && Sorts the mapping object so that the appearance of transforms are prioritized by the target.


Actually I think I meant the "order" property
http://publib.boulder.ibm.com/infocenter/wmbhelp/v8r0m0/topic/com.ibm.etools.mft.doc/cm28858_.htm


Thanks for the links. I achieved sorting using "Sort" property but nothing found about the "Sort property" in InfoCenter.
Back to top
View user's profile Send private message
mqsiuser
PostPosted: Tue Aug 06, 2013 12:56 am    Post subject: Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

mqjeff wrote:
It's easy enough to write an insertion sort in ESQL to build the output tree

I don't understand when people suggest alternatives to something that has been thoroughly discussed before. To properly implement ESQL-Sorting: Its not trivial (to consider all constraints) and best of all... it has been done before. If you found something (much) better post the relevant parts (of your insertion-sort algorithm) so we can review it.

And XSLT-Sorting can lead to memory consumption problems (as stated in one of the threads in this forum).

And ofc. if you can be wasteful with resources you can do so.
_________________
Just use REFERENCEs
Back to top
View user's profile Send private message
dogorsy
PostPosted: Tue Aug 06, 2013 1:53 am    Post subject: Reply with quote

Knight

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

mqsiuser wrote:
mqjeff wrote:
It's easy enough to write an insertion sort in ESQL to build the output tree

I don't understand when people suggest alternatives to something that has been thoroughly discussed before. To properly implement ESQL-Sorting: Its not trivial (to consider all constraints) and best of all... it has been done before. If you found something (much) better post the relevant parts (of your insertion-sort algorithm) so we can review it.

And XSLT-Sorting can lead to memory consumption problems (as stated in one of the threads in this forum).

And ofc. if you can be wasteful with resources you can do so.


it would be nice to have ORDER BY in ESQL SELECT
Back to top
View user's profile Send private message
smdavies99
PostPosted: Tue Aug 06, 2013 2:08 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

[quote="dogorsy"

it would be nice to have ORDER BY in ESQL SELECT[/quote]

you could always create an improvement request??????


_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
mqsiuser
PostPosted: Tue Aug 06, 2013 3:33 am    Post subject: Reply with quote

Yatiri

Joined: 15 Apr 2008
Posts: 637
Location: Germany

Message Transformation is different than Databases!

Nothing better could happen than to have ESQL.

And sort implemented within it

I am looking forward to mqjeff's reply.
_________________
Just use REFERENCEs
Back to top
View user's profile Send private message
dogorsy
PostPosted: Tue Aug 06, 2013 3:49 am    Post subject: Reply with quote

Knight

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

mqsiuser wrote:

I am looking forward to mqjeff's reply.


or mgk's !

order by for database selects is easy, just pass it on to the DB. So WMB should implement it only for Select from message tree.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Tue Aug 06, 2013 4:06 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

dogorsy wrote:


order by for database selects is easy, just pass it on to the DB. So WMB should implement it only for Select from message tree.


This is not possible in some sites because PASSTHRU is banned because some IBM consultant (Global Services) once said that it was not 'best practice'.

Now wheres the Ostrich-with-head-in-sand Emoticon when you need it?
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
dogorsy
PostPosted: Tue Aug 06, 2013 5:23 am    Post subject: Reply with quote

Knight

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

smdavies99 wrote:
dogorsy wrote:


order by for database selects is easy, just pass it on to the DB. So WMB should implement it only for Select from message tree.


This is not possible in some sites because PASSTHRU is banned because some IBM consultant (Global Services) once said that it was not 'best practice'.

Now wheres the Ostrich-with-head-in-sand Emoticon when you need it?


Sorry, I think you misunderstood my post, I was talking about implementing ESQL SELECT ORDER BY, I said for ESQL SELECT from database it would be easy to implement, just syntax check and pass it to the database, I never mentioned PASSTHRU.
Back to top
View user's profile Send private message
kash3338
PostPosted: Tue Aug 06, 2013 5:58 am    Post subject: Reply with quote

Shaman

Joined: 08 Feb 2009
Posts: 709
Location: Chennai, India

dogorsy wrote:
Sorry, I think you misunderstood my post, I was talking about implementing ESQL SELECT ORDER BY, I said for ESQL SELECT from database it would be easy to implement, just syntax check and pass it to the database, I never mentioned PASSTHRU.


The above point is not so clear.

You mean ESQL SELECT ORDER BY? There is no ORDER BY in ESQL, you need PASSTHRU to implement one.

The point made by smdavies99 is that to implement ORDER BY in ESQL, you need to use PASSTHRU and that is not used ta many places.
Back to top
View user's profile Send private message Send e-mail
lancelotlinc
PostPosted: Tue Aug 06, 2013 6:04 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

kash3338 wrote:
dogorsy wrote:
Sorry, I think you misunderstood my post, I was talking about implementing ESQL SELECT ORDER BY, I said for ESQL SELECT from database it would be easy to implement, just syntax check and pass it to the database, I never mentioned PASSTHRU.


The above point is not so clear.

You mean ESQL SELECT ORDER BY? There is no ORDER BY in ESQL, you need PASSTHRU to implement one.

The point made by smdavies99 is that to implement ORDER BY in ESQL, you need to use PASSTHRU and that is not used ta many places.


I don't know of many sites that outlaw 'PASSTHRU'. This becomes a challenge to management to justify the logic of creating a rule:

- You are not allowed to use 'PASSTHRU'
- You are not allowed to use Java.
- You are not allowed to use ESQL.

These are dictates that have little technical merit. 'Just because' is not a good reason. No node or language in WMB is mutually exclusive to the other. Good developers use what they need. If they need PASSTHRU, Java, or ESQL, they should use them. Thats what developing software is all about: making intelligent choices. Laws cannot force under-skilled people to make good choices.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
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 » Sorting in Message Broker using XSL
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.