Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 24th, 2006, 08:55 AM
Registered User
 
Join Date: Jan 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default Not able to implement the given logic in my XSLT



Hi all,
My problem is that I have to write a xslt that will be applied to the xml document
Here is a simple xml input file:--


In put XML file(Input.xml) ..

 In this file < transaction > node may be in multiple numbers (1 to many)..

<response>
<transaction type="FXCH" id="0">
<returnCode>XX</returnCode>
</transaction>

<transaction type="TRFD" id="1">
<returnCode>XX</returnCode
</transaction>

<transaction type=" FXCH " id="1">
……
</transaction>

……..
……
…….
………

</response>

Here XX can have value any one of them..
00,01,02,,03,04, 98,99



 Here is my Output xml file (Output.xml)

             <response>
        <rtnCode> Some values here (YY)<rtnCode>
        </ response >



Now the logic for the value YY is

  1. If any one of < returnCode > have value 98 or 99 then <rtncode> will be OFF.
  1.1 else if any one of < returnCode > have value 01 or 02 then <rtncode> will be HFL.(but not 98/99)
1.2 I else if any one of < returnCode > have value 03 or 04 then <rtncode> will be HFL.(but not 98/99 and 01 02)
1.3 If all < returnCode > have value 00 then rtnCode will have ‘SUC’



Precedence needed to be followed..

Now the problem is how can I implement this logic ..

 Kindly help me to write this logic in my xslt

thanks in advance ..

regards
Ashu
 
Old January 24th, 2006, 09:19 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

This translates directly into an xsl:choose:

<xsl:choose>
<xsl:when test="/response/transaction/returnCode = ('98', '99')">
  <rtncode>0FF</rtncode>
</xsl:when>
<xsl:when test="/response/transaction/returnCode = ('01', '02')">
  <rtncode>HFL</rtncode>
</xsl:when>
etc.

I've used the XPath 2.0 notation X=(a,b) here -- in XPath 1.0 you need to expand this to (X=a or X=b). Whether it's 1.0 or 2.0, if X selects multiple nodes then the condition is true if any of them match.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old January 27th, 2006, 07:24 AM
Registered User
 
Join Date: Jan 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks kay..

its working...






Similar Threads
Thread Thread Starter Forum Replies Last Post
help to solve the logic pradeepn XSLT 4 May 22nd, 2007 06:07 AM
And/Or Logic??? ninel SQL Server 2000 2 February 9th, 2007 11:33 AM
XSLT Looping Logic - Very Urgent ujayaraman XSLT 2 March 3rd, 2005 10:42 AM
Mixing Data access logic and business logic polrtex BOOK: Professional Jakarta Struts 0 December 15th, 2003 07:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.