473,385 Members | 1,325 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

XSL on the client

Hi,
I am trying to develop a stand alone application to run under IE6.
I have the following xml file sample.xml:
<?xml version="1.0" encoding="UTF-8"?>
<cardset>
<card>
<name>Arrest</name>
<cost>2W</cost>
</card>
</cardset>

I have the following xsl file sample.xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet>
<xsl:template match="/">
<xsl:for-each select="cardset/card">
<div>
<span><xsl:value-of select="name"/></span>
<span><xsl:value-of select="cost"/></span>
</div>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

I have the following html file sample.htm
<html>
<head>
<script type="text/javascript">
function doit() {
// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("sample.xml")
// Load XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("sample.xsl")
// Transform
var e = document.getElementById("thebox")
e.innerHTML = xml.transformNode(xsl)
//alert(xml.transformNode(xsl))
}
</script>
</head>
<body>
<form><input type="button" value="Do it" onClick="doit()"></form>
<p id="thebox"></p>
</body>
</html>

What I am trying to do is open the html file click the button then have the
output of the transformed xml file sent to the innerHTML of the paragragh.

I can't seem to get it to work. Any thoughts or comments on how to get this
working would be greatly appreciated.
Dec 22 '05 #1
4 1261
On Thu, 22 Dec 2005 11:26:30 GMT, "Martin Collins"
<ma****@nospam.edu-tech.com.au> wrote:
I can't seem to get it to work. Any thoughts or comments on how to get this
working would be greatly appreciated.


Test for error conditions, particularly after your .load() methods
Chances are that it's just failing to find one of the resources.

Also read a book on AJAX. You don't need to be _quite_ so M$oft specific
in how you do this.
Dec 22 '05 #2
> Test for error conditions, particularly after your .load() methods
Chances are that it's just failing to find one of the resources.


I know that the load methods work and that the files are being found. If I
uncomment the alert message at the end then I can see that the XML is being
parsed thru the XSL file. One funny thing though is that it displays UTF-16
instead of UTF-8.

Dec 22 '05 #3
The software application is not going to be deployed in a web
environment. It runs as a stand alone application on my pc. I can
choose to use whatever webbrowser I like I suppose. I have done some
more reading and think that since I am a newbie I may have not be going
about things the right way. Here is my problem:

I have multiple XML files using the following schema:
<set>
<card>
<name>some_name</name>
<cost>some_cost</cost>
</card>
.... more card records ...
</set>
From an html page I want to be able to click a button that will cause

card records from several XML files to be rendered dynamically in the
current html page.

I figure that I need the button to call a JavaScript function. The
JavaScript function runs the following algorithim:
Load XSL file
For each XML file Do
Loads XML file
Transform the XML into html
Write html to the innerHTML of appropriate html element
End For

Is this application model feasable? Or am I such a total newbie that I
have completely missed the point of these technologies?

Dec 23 '05 #4


Martin Collins wrote:

I have the following xsl file sample.xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet>


That should be
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
--

Martin Honnen
http://JavaScript.FAQTs.com/
Dec 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Matt | last post by:
I think this is the basic concept in ASP server-side development. My boss told me web application is NOT client-server application. I argued with him because browser is the client, and the server...
15
by: Michael Rybak | last post by:
hi, everyone. I'm writing a 2-players game that should support network mode. I'm now testing it on 1 PC since I don't have 2. I directly use sockets, and both client and server do...
18
by: cjl | last post by:
Hey all: I know that it is silly in the age of Google to 'lose' something on the internet, but I recently checked out a project that had implemented a database with a subset of SQL in pure...
2
by: Raquel | last post by:
How do I know whether the 'runtime client' and the 'application development client' are installed on my machine? When I issue the command "db2licm -l", it gives the following output: Product...
6
by: Ken Allen | last post by:
I am relatively new to .Net and C#, but I hav ebeen programing in other languages and done some COM work for a number of years. I am attempting to understand how to map an older program...
4
by: rs | last post by:
how I the client tell the server that the socket is closed? or this there an even that informs the server that the clients socket is close? Oh, I am using vb.net 2003 Thanks
2
by: J Huntley Palmer | last post by:
I am having a horrific time integrating uw-imap's c-client for imap support in php. The problem is a whole bunch of "Text relocation remains referenced against symbol" errors during linking....
0
by: khu84 | last post by:
Here is client server very simple code, seems to work with telnet but with with web client code gives blank output. Following is the server code:- <?php function...
2
by: nsaffary | last post by:
hi I hava a client/server program that run correctly when i run it in one computer(local) but when I run client on a one computer and run server run on another, connection does not stablish.(I set...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.