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 May 3rd, 2006, 12:35 PM
Registered User
 
Join Date: May 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using Ajax with XSLT

Hi
I am working on a simple web application using xml, xslt and ajax.

My xml file is as follows
=====
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="Hotels.xsl"?>
<Services>
    <Service>
        <Hotels type="radio" title="Hotel" groupname="service" default="true"/>
        <HotelsFlights type="radio" title="Flight+Hotel" groupname="service"/>
    </Service>

    <Hotels>
        <Destination title_d="Destination :">
            <DestinationPlace type="OPTION" id="" title_d="Select Destination" value_d="Select Destination" defalut="true"/>
            <DestinationPlace type="OPTION" id="" title_d="Aruba" value_d="Aruba" />
            <DestinationPlace type="OPTION" id="" title_d="Washington" value_d="Washington" />
        </Destination>

        <HotelChoice title_hc="Hotels :">
            <choice type="OPTION" id=" " title_h="AmsterDam Manor Beach" value_h="AmsterDam Manor Beach"/>
            <choice type="OPTION" id=" " title_h="Wyndham Aruba Beach" value_h="Wyndham Aruba Beach"/>
        </HotelChoice>

        </Hotels>
</Services>

=========
And the xsl file as follows
======
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:lxslt="http://xml.apache.org/xslt" xmlns:totalSys="TotalSystem" extension-element-prefixes="totalSys">

<lxslt:component prefix="totalSys" elements="resetTotal customerInfo" functions="radioFunc">
<lxslt:script lang="javascript">
function radioFunc()
{
alert("Hai");
}
</lxslt:script>
</lxslt:component>

<xsl:template match="/">
    <xsl:apply-templates/>
</xsl:template>

<xsl:template match="Services" >
    <html>
    <body>
    <table bgcolor="lightgreen" width="350" height="200" border="1" >
    <tr><td>
    <xsl:apply-templates/>
    </td></tr>
    </table>
    </body>
    </html>

</xsl:template>

<xsl:template match="Service">
    <table border="0" align="center" valign="top"><tr>
    <xsl:for-each select="*">
        <td align="left"><xsl:value-of select="@title"/></td>

        <td align="center">

        <input type="{@type}" onClick = "radioFunc()">
            <xsl:attribute name="Name">
                <xsl:value-of select="@groupname"/>
            </xsl:attribute>

            <xsl:attribute name="value">
                <xsl:value-of select="@value"/>
            </xsl:attribute>

            <xsl:if test="@default='true'">
                <xsl:attribute name="checked"/>
            </xsl:if>
        </input>

        </td>

    </xsl:for-each>
    </tr></table><br/>
</xsl:template>

<xsl:template match="Hotels/Destination">
<xsl:value-of select="@title_d"/>

    <SELECT id="dest" name="dest" onchange="showHint(this.selectedIndex);">
         <xsl:for-each select="*">
        <xsl:element name="{@type}">
            <xsl:value-of select="@value_d"/>
        </xsl:element>
       </xsl:for-each>
    </SELECT>
</xsl:template>

<xsl:template match="Hotels/HotelChoice">
<xsl:value-of select="@title_hc"/>

     <SELECT id="hcid" name="hcid">
    <xsl:for-each select="*">
        <xsl:element name="{@type}">
            <xsl:value-of select="@value_h"/>
        </xsl:element>
    </xsl:for-each>
     </SELECT><br/>
 </xsl:template>

</xsl:stylesheet>
=========

I have written some ajax code when there is onchange event on destination select box.From the Ajax i am getting output in xml format like

<HOTELLIST HOTELS="Renaissance,Vandetta,Viceroy">

From this i have to assign the hotels value to the hotels select box.
I am not able to write the code to assign these values to the select box specified in the xml.

regards,
raj










Similar Threads
Thread Thread Starter Forum Replies Last Post
XML XSLT AJAX and Database Advice Pls newbieboobers XSLT 2 March 20th, 2008 08:53 AM
Recommend an AJAX IDE - JoyiStar AJAX WebShop. kingstar Ajax 4 December 15th, 2006 05:12 AM
New Ajax article: Creating an Ajax Search W jminatel BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 1 May 11th, 2006 03:45 PM
new Ajax article: Creating an Ajax Search Widget jminatel Ajax 0 May 11th, 2006 02:50 PM
New Ajax Article: Ajax Submission Throttling jminatel Ajax 0 April 11th, 2006 08:00 PM





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