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, 02:14 AM
Registered User
 
Join Date: Jan 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to abhishek verma
Default having problems in for each..

Hi
My problem is that I have a write the xslt with will be applied to the xml document to change the structure .
I have written a java class which takes two parameter one is the xml files and the xslt files.
 It applies the xslt on the xml files and return the desired xml file..
Here is a simple xml input file:--
Here in put is a dynamic generated file it mat contain one transaction element or two ..
With a attribute as FXIB or FXIC ..

<? xml version="1.0" encoding="UTF-8"?>
<response>

<transaction type=" FXIB">
    <ppbExchangeRate1>FXIB</ppbExchangeRate1>
    <ppbExchangeRate2>CC</ppbExchangeRate2>
</transaction>
<transaction type=" FXIC">
    <ppbExchangeRate1>FXIC</ppbExchangeRate1>
    <ppbExchangeRate2>CCC</ppbExchangeRate2>
</transaction>
</response>



And my out put xml should be like

<?xml version="1.0" encoding="UTF-8"?>
<response>
    <header>
        <rtnCode></rtnCode>
        <rtnMsg></rtnMsg>
    </header>
    <txnInfo>
        <buyPpbRate1>values from ppbExchangeRate1 where transaction type=" FXIB"></buyPpbRate1>

        <buyPpbRate2> values from ppbExchangeRate2 where transaction type=" FXIB"</buyPpbRate2>
        <sellPpbRate1> values from ppbExchangeRate1 where transaction type=" FXIC"></sellPpbRate1>
        <sellPpbRate2> values from ppbExchangeRate2 where transaction type=" FXIC"></sellPpbRate2>

    </txnInfo>
</response>
So how should I write my Xslt logic..



Any help is appreciated

Regards
Abhishek
HP Solutions
 
Old January 24th, 2006, 05:29 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Your subject line says you're having problems with for-each but the body of the message doesn't say what your problems are, so it's hard to help you with them. You've written your pseudo-code as a fill-in-the-blanks stylesheet, so that's the way I would code it:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet ...>
<xsl:template match="/"
<response>
    <header>
        <rtnCode></rtnCode>
        <rtnMsg></rtnMsg>
    </header>
    <txnInfo>
        <buyPpbRate1><xsl:value-of select="/response/transaction[@type=" FXIB"]/ppbExchanegRate1"/></buyPpbRate1>

        <buyPpbRate2>xsl:value-of select="/response/transaction[@type=" FXIB"]/ppbExchanegRate2"/></buyPpbRate2>
        <sellPpbRate1> etc</sellPpbRate1>
        <sellPpbRate2>etc</sellPpbRate2>

    </txnInfo>
</response>
</xsl:template>
</xsl:stylesheet>


Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems already! KennySargent BOOK: Professional XNA Programming 2nd Edition ISBN: 978-0-470-26128-6 4 April 7th, 2008 03:36 AM
Have 2 problems so far... Soulcatcher BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 June 20th, 2007 12:57 PM
c problems saurabh1983in C++ Programming 6 November 29th, 2005 04:23 AM
validate.asp problems and logon.asp problems p2ptolu Classic ASP Databases 0 February 16th, 2005 02:34 PM
Problems kilika Javascript 1 October 3rd, 2003 02:42 AM





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