Any of you HTML & XML guru's out there...

SunnyD

Belgian Waffler
Jan 2, 2001
32,675
146
106
www.neftastic.com
I'm such a n00b. I'm a programmer by trade, but I'm clueless with the newer technologies, so bear with me.

I'm trying to figure out how you take an XML document (data) off of a provider's server (via URL), run it through an XML Transform, and put the output content into your own webpage.

Like basically - website X has a dynamically updated XML document (updated, say, every hour) that give the status on something arbitrary, among other data... on MY website, I have a page that is intended to show the status of that something arbitrary based on the data from the XML document.

I know how to write an XML Transform using XSLT, but I don't know how to get the contents of that transformed data into my own webpage.

Any help will be appreciated.

SunnyD
 

Alphathree33

Platinum Member
Dec 1, 2000
2,419
0
0
Although my XML experience is limited, I guarantee that there is a good tutorial on this topic on MSDN.
 

Ameesh

Lifer
Apr 3, 2001
23,686
1
0
the easiest and most appropiate way is by making an XSLT for the XML data document, everytime you load the document the transform will automatically run and create what ever you want it to create whether it is an html page or another xml document or whatever. most people just have it create an html document to present the XML in a nice fashion.
 

SunnyD

Belgian Waffler
Jan 2, 2001
32,675
146
106
www.neftastic.com
Originally posted by: SunnyD
I'm such a n00b. I'm a programmer by trade, but I'm clueless with the newer technologies, so bear with me.

I'm trying to figure out how you take an XML document (data) off of a provider's server (via URL), run it through an XML Transform, and put the output content into your own webpage.

Like basically - website X has a dynamically updated XML document (updated, say, every hour) that give the status on something arbitrary, among other data... on MY website, I have a page that is intended to show the status of that something arbitrary based on the data from the XML document.

I know how to write an XML Transform using XSLT, but I don't know how to get the contents of that transformed data into my own webpage.

Any help will be appreciated.

SunnyD

Just to reiterate -- since noone actually ANSWERED my question (Ameesh, you were close, but not), we'll try again.

I know how to use an XSLT transform to make the data into HTML. However, the only way I know how to do that is to use the stylesheet tag inside the XML source file, as in:
[*]<?xml-stylesheet type="text/xsl" href="xmltest.xsl"?>[/li]

The only problem with this is, as I said, the XML source file IS GENERATED ON AND COMES FROM SOMEONE ELSES SERVER. Thus, I cannot add the tag.

Catch what I'm saying now?

So basically what I want to do (which sound like server-side scripting, yes I know PHP is probably an answer, but it seems like something else should exist already) is the following:

1- User requests a web page from my server (ie: my template)
2- The web page contacts the XML source for an up-to-date XML file
3- The XML file is sent through an XML transform to generate only the data I want
4- The transformed XML data is then placed into the outgoing web page from my server

So lets see what you guys come up with now.

SunnyD
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
Here's how I've done it in the past...

You simply need to issue an HTTP GET/POST request to the server, retrieve the result, load it into a DOM and transfer the contents by applying an XSLT stylesheet. You didn't say what platform you're on, what technologies you're using, etc., so I'll be generic. I've done this very thing using MS' XMLHTTP component, raw sockets, Perl, C, C#, ad nauseum. It's all the same; let me know if you want examples.

- Use an HTTP component (XMLHTTP, AspTear, .NET's FCL WebRequest class, ...) to issue an HTTP GET/POST request to the server.
- Read the response.
- Load the response into a DOM object (e.g MSXML2.DOMDocument40)
- Transform the contents of the DOM by applying an XSLT stylesheet (e.g. via MSXML's transform method)
- Write the results to the output stream

Make sense? Provide more specifics of what language you're using and I can expound on specific implementations...
 

Ameesh

Lifer
Apr 3, 2001
23,686
1
0
in asp you just load up both the xml and xslt into dom and then use the transform function, violioa you are done.

here is a sample code snipet.



<%@ LANGUAGE = JScript %>
<%
// Set the source and style sheet locations here.
var sourceFile = Server.MapPath("simple.xml");
var styleFile = Server.MapPath("simple.xsl");

// Load the XML.
var source = Server.CreateObject("MSXML2.DOMDocument.4.0");
source.async = false;
source.resolveExternals = false;
source.load(sourceFile);
// Load the XSLT.
var style = Server.CreateObject("MSXML2.DOMDocument.4.0");
style.async = false;
style.resolveExternals = false;
style.load(styleFile);
Response.Write(source.transformNode(style));
%>
 

Ameesh

Lifer
Apr 3, 2001
23,686
1
0
descartes said exactly what i showed.

(in case you are confused we gave the same answer)
 

SunnyD

Belgian Waffler
Jan 2, 2001
32,675
146
106
www.neftastic.com
Ooooohkay, NOW we're getting somewhere.

I understand where you guys are comin from, and I did come across that somewhere using JavaScript, which is nice 'n dandy.

Of course, you both say "load" it up using a DOM object, MSXML. Meaning... platforms outside of Microsoft are unable to deal with my web page. I was thinking there's something completely serverside that can be done without using a something Microsoft or Internet Explorer proprietary.

You can't just load up a reference in HTML to call the XML page into an appropriate stylesheet? Or something like that? It's been so long since I've done web programming, like I said, I'm n00b-ish.

SunnyD
 

Ameesh

Lifer
Apr 3, 2001
23,686
1
0
Originally posted by: SunnyD
Ooooohkay, NOW we're getting somewhere.

I understand where you guys are comin from, and I did come across that somewhere using JavaScript, which is nice 'n dandy.

Of course, you both say "load" it up using a DOM object, MSXML. Meaning... platforms outside of Microsoft are unable to deal with my web page. I was thinking there's something completely serverside that can be done without using a something Microsoft or Internet Explorer proprietary.

You can't just load up a reference in HTML to call the XML page into an appropriate stylesheet? Or something like that? It's been so long since I've done web programming, like I said, I'm n00b-ish.

SunnyD

this is a server side solution. when the webpage is being created for the client the server uses msxml not the client.
 

SunnyD

Belgian Waffler
Jan 2, 2001
32,675
146
106
www.neftastic.com
Originally posted by: Ameesh

this is a server side solution. when the webpage is being created for the client the server uses msxml not the client.

Yes, but like I said, calling into MSXML is a completely Microsoft-only implementation, meaning that if I did that, my web page wouldn't work on browsers running in a non-MS world (if there is such a thing, lol).

So what I'm wanting to do is completely only serverside then? Argh, I mean, duh, yes, it is serverside, that's now obvious. But what I'm asking is if I'm *forced* into useing a serverside scripting language now? This can't be done/parsed just through a plain HTML document?

I think if that question is answered, I know where to look from there.

SunnyD

 

IcemanJer

Diamond Member
Mar 9, 2001
4,307
0
0
Yes, but like I said, calling into MSXML is a completely Microsoft-only implementation, meaning that if I did that, my web page wouldn't work on browsers running in a non-MS world (if there is such a thing, lol).
No no, you don't understand. if you have the code snippet that Ameesh posted, that code is run on the serverside, and what's being generated and sent to the client is plain-old HTML that any self-deserving browser can understand. Doesn't have to be IE with MSXML.

The only requirement is that *you* on the server side can support MSXML DOM.
 

joohang

Lifer
Oct 22, 2000
12,340
1
0
Originally posted by: SunnyD
Originally posted by: Ameesh

this is a server side solution. when the webpage is being created for the client the server uses msxml not the client.

Yes, but like I said, calling into MSXML is a completely Microsoft-only implementation, meaning that if I did that, my web page wouldn't work on browsers running in a non-MS world (if there is such a thing, lol).

So what I'm wanting to do is completely only serverside then? Argh, I mean, duh, yes, it is serverside, that's now obvious. But what I'm asking is if I'm *forced* into useing a serverside scripting language now? This can't be done/parsed just through a plain HTML document?

I think if that question is answered, I know where to look from there.

SunnyD

Would you rather code this up in DHTML then?

It's possible, but it's not a whole lot different than doing this on the server-side. And it is actually more troublesome because you are pretty much limited to IE5+ and limited number of Mozilla clients. Even then, you need to worry about the client's MSXML versions because 2.x, 3.x and 4.x have different feature sets and handle some things differently. Or maybe some clients have an XML parser and/or XSLT transformer other than MSXML.

My advise is that you read Descartes' and Ameesh's posts. If you don't like server-side scripting, write up a COM object. Or use Apache XML on Java or whatever you prefer.
 

SunnyD

Belgian Waffler
Jan 2, 2001
32,675
146
106
www.neftastic.com
OooooooohhhhhHHH!

Okay, I get it. I thought all the "scripting" was done client-side. See, told ya I'm a n00b with this web stuff.

So basically the above example applies to a server running on a Windows machine, Apache or IIS, correct?

More than likely on a *nix machine I'd be doing this in PHP or Perl (probably PHP) correct?

See, ya learn something new every day. :)
 

joohang

Lifer
Oct 22, 2000
12,340
1
0
Originally posted by: SunnyD
OooooooohhhhhHHH!

Okay, I get it. I thought all the "scripting" was done client-side. See, told ya I'm a n00b with this web stuff.

So basically the above example applies to a server running on a Windows machine, Apache or IIS, correct?

More than likely on a *nix machine I'd be doing this in PHP or Perl (probably PHP) correct?

See, ya learn something new every day. :)

Yup.

As long as they can make use some sort of XML parser that is able to transform XML documents through XSLT. You may use pretty much anything.

BTW, Microsoft did an excellent job with MSXML. And their MSDN documentation on XML rocks. I've seen developers who use Apache XML with Java on Linux who referred to the MSDN documentation. It conformed very well to the standards and they quite clearly state it in the documentation if you are reading about a Microsoft proprietary extensions, which are mostly for scripting within XSLT and a few XPath functions.