update MULTIPLE elements of an HTML page using Ajax and XSL

M

MORALBAROMETER

Hi all,
I want to update MULTIPLE elements of an HTML page using Ajax. for
this reason i my response is an xml document. I want to use XSL at the
client side to update these elements. How can i achieve this?
I will be very greatefull for any help.
Have a look below
=====================================================
Response from Server using HttpRequest Object
=====================================================

<?xml version="1.0" encoding="UTF-8"?>
<responses>
<response id="1">
<div> my name is ivo sumelong in berlin and i will be coming to london
next week</div>
</response>
<response id="2">
<div> great peopele strive for greater things as well realised they
are ambitions
</div>
</response>
<response id="3">
<div> great peopele strive for greater things as well realised they
are ambitions
</div>
</response>
<htmlUpdateInstruction>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform" >
<xsl:param name="action" />
<xsl:template match="/">
<name > <xsl:value-of select="/response"/>
</name>
</xsl:template>
</xsl:stylesheet>

</htmlUpdateInstruction>

</responses>

=====================================================
Page below to be updated
=====================================================


<!-- <?xml version="1.0" encoding="UTF-8"?> -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TODO supply a title</title>
</head>
<body>
<a onClick="ava:ajaxised()" >update page</a>
<div id="1">
TO update content from response 1
</div >
<div id="2">
TO update content response 2
</div >
<div id="3">
TO update content response 3
</div >
</p>
</body>
</html>




=====================================================
Processing the response(my ideas)
1. Using Javascript and DOM. i could update the various DIVS
2. Using XSL(embeded in xml of server reponse) and JavaScript. This is
an Idea but
can realise it only at server side. i don't know how to go about it at
the client side.
=====================================================
-thoughts.
1. get the embeded XSL in reponse to be used for transformation
2. use the initial html page as result of transformation
3. use the initial html page and the response (xml ) as transformation
source
4.problems writing the xsl( my idea is to loop through the reponse and
search the id, then check the html element with such and id if found
then update the content with that of the response)

I will be glad if someone can help me in any way.
thanks
 
O

OmegaJunior

Hi all,
I want to update MULTIPLE elements of an HTML page using Ajax. for
this reason i my response is an xml document. I want to use XSL at the
client side to update these elements. How can i achieve this?
I will be very greatefull for any help.
Have a look below
=====================================================
Response from Server using HttpRequest Object
=====================================================

<?xml version="1.0" encoding="UTF-8"?>
<responses>
<response id="1">
<div> my name is ivo sumelong in berlin and i will be coming to london
next week</div>
</response>
<response id="2">
<div> great peopele strive for greater things as well realised they
are ambitions
</div>
</response>
<response id="3">
<div> great peopele strive for greater things as well realised they
are ambitions
</div>
</response>
<htmlUpdateInstruction>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform" >
<xsl:param name="action" />
<xsl:template match="/">
<name > <xsl:value-of select="/response"/>
</name>
</xsl:template>
</xsl:stylesheet>

</htmlUpdateInstruction>

</responses>

=====================================================
Page below to be updated
=====================================================


<!-- <?xml version="1.0" encoding="UTF-8"?> -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TODO supply a title</title>
</head>
<body>
<a onClick="ava:ajaxised()" >update page</a>
<div id="1">
TO update content from response 1
</div >
<div id="2">
TO update content response 2
</div >
<div id="3">
TO update content response 3
</div >
</p>
</body>
</html>




=====================================================
Processing the response(my ideas)
1. Using Javascript and DOM. i could update the various DIVS
2. Using XSL(embeded in xml of server reponse) and JavaScript. This is
an Idea but
can realise it only at server side. i don't know how to go about it at
the client side.
=====================================================
-thoughts.
1. get the embeded XSL in reponse to be used for transformation
2. use the initial html page as result of transformation
3. use the initial html page and the response (xml ) as transformation
source
4.problems writing the xsl( my idea is to loop through the reponse and
search the id, then check the html element with such and id if found
then update the content with that of the response)

I will be glad if someone can help me in any way.
thanks

Go with your first idea. This will work in all DOM-savvy browsers.

XSLT is not designed to run in a browser. Any browser implementation will
inevitably lead to compatibility problems.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top