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 » XSL Query

Post new topic  Reply to topic
 XSL Query « View previous topic :: View next topic » 
Author Message
mqmaran
PostPosted: Fri Jun 19, 2009 12:44 am    Post subject: XSL Query Reply with quote

Newbie

Joined: 21 May 2009
Posts: 2

Hi,

I'm a newbie to XSL. We have a requirment as such I shud modify only 2 fields in the Inbound XML to the outgoing XML where the Interface definition shares the same API' calls ( EmpDetails in the below example).

The sample XSL's I've gone through in net, I found, XSL only able to generate a new XML structure & I cudnt find any option to edit the Inbound data just for few fields & leave the root element & remaining structure untouched.

Ex:
Input:
<EmpDetails>
<Name>Hi</Name>
<Age>24</Age>
< blah... blah >
</EmpDetails>

Expected Output:
<EmpDetails>
<Name>Maran</Name>
<Age>24</Age>
< blah... blah >
</EmpDetails>

To generate the above expected output, I can do very simple in ESQL,
SET OutputRoot.XML.EmpDetails = InputRoot.XML.EmpDetails;
SET OutputRoot.XML.EmpDetails.Name= 'Maran' ;

Do we have the similar option in XSL? If yes, Please let me know.
Back to top
View user's profile Send private message
mymq
PostPosted: Sat Jun 20, 2009 6:50 pm    Post subject: Reply with quote

Centurion

Joined: 01 Mar 2007
Posts: 101
Location: US-Greenwille

Do you have any requirment to use XSL?
_________________
--SRK--
Back to top
View user's profile Send private message Send e-mail
harish_td
PostPosted: Sun Jun 21, 2009 7:42 pm    Post subject: Reply with quote

Master

Joined: 13 Feb 2006
Posts: 236

This is what some free time and some Google can do
Code:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:output indent="yes"/>
   <xsl:template match="node() | @*">
      <xsl:choose>
         <!-- Test Name of the tag and rename tag to something else -->
         <xsl:when test="name()='Age'">
            <xsl:element name="NewAge">
               <xsl:value-of select="node()"/>
            </xsl:element>
         </xsl:when>
         <!-- Test Value of the tag and then assign value to something else -->
         <xsl:when test="text()='Hi'">
            <xsl:variable name="element_name">
               <xsl:value-of select="name()"/>
            </xsl:variable>
            <xsl:element name="{$element_name}">
               <xsl:value-of select="'James Bond'"/>
            </xsl:element>
         </xsl:when>
         <xsl:otherwise>
            <!--The rest of the transform simply copies the "input" context to the "output" context with no change to the payload-->
            <!-- Equivalent to CopyEntireMessage() in ESQL -->
            <xsl:copy>
               <xsl:apply-templates select="@*"/>
               <xsl:apply-templates/>
            </xsl:copy>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:template>
</xsl:stylesheet>
Back to top
View user's profile Send private message Yahoo Messenger
goffinf
PostPosted: Sun Jun 28, 2009 9:38 am    Post subject: Re: XSL Query Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

mqmaran wrote:
Hi,
I cudnt find any option to edit the Inbound data


Thats because XSL(T) isn't concerned with modifying input data (thats not possible), only creating the output tree (from the input or not).

As far as creating output which processes one specific aspect of the input, the most typical approach is to create a 'template' with a 'match' containing the XPath expression that points to the part of the input tree you want to process, and then within that template, code whatever processing you need for your required output.

If you want everything else from the input to be copied to output look up (on Google) XSLT and 'identity template'.

Fraser.
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 » XSL Query
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.