|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
XSL Query |
« View previous topic :: View next topic » |
Author |
Message
|
mqmaran |
Posted: Fri Jun 19, 2009 12:44 am Post subject: XSL Query |
|
|
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 |
|
 |
mymq |
Posted: Sat Jun 20, 2009 6:50 pm Post subject: |
|
|
Centurion
Joined: 01 Mar 2007 Posts: 101 Location: US-Greenwille
|
Do you have any requirment to use XSL? _________________ --SRK-- |
|
Back to top |
|
 |
harish_td |
Posted: Sun Jun 21, 2009 7:42 pm Post subject: |
|
|
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 |
|
 |
goffinf |
Posted: Sun Jun 28, 2009 9:38 am Post subject: Re: XSL Query |
|
|
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 |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|