Transform XML to HTML only for Browsers

Mungo Henning

Usenet Archive
Joined
Oct 20, 2004
Messages
1
Reaction score
0
Hi Folks,
Beg pardon for this simplistic question (I've searched via Google but got lost with all the terminology).

An application I have created dumps out some data in XML format to a file.

I want the file to remain unchanged so that other applications can open it and read the data contained in there.

But, if someone points a browser at the file I want the XML file to be transformed via an XSLT script into HTML so that it looks pretty on the screen instead of collections of angled-bracketed data lumps.

So the transform only occurs when some browser looks at the file; any other program looking at the file will see only plain XML.

Can this be engineered?

Any help appreciated; thanks in advance

Mungo Henning
 

Johannes Koch

Usenet Archive
Joined
Nov 14, 2000
Messages
801
Reaction score
0
Mungo said:
An application I have created dumps out some data in XML format to a file.

I want the file to remain unchanged so that other applications can open it and read the data contained in there.

But, if someone points a browser at the file I want the XML file to be transformed via an XSLT script into HTML so that it looks pretty on the screen instead of collections of angled-bracketed data lumps.

So the transform only occurs when some browser looks at the file; any other program looking at the file will see only plain XML.

You may take a look at the HTTP Accept header. If the requesting user agent wants text/html, you perform the transformation, otherwise send the raw XML. And make sure that the 'other applications' don't order text/html in the Accept header.
 

Manuel Collado

Usenet Archive
Joined
Jun 19, 2002
Messages
93
Reaction score
0
Mungo said:
Hi Folks,
Beg pardon for this simplistic question (I've searched via Google but got lost with all the terminology).

An application I have created dumps out some data in XML format to a file.

I want the file to remain unchanged so that other applications can open it and read the data contained in there.

But, if someone points a browser at the file I want the XML file to be transformed via an XSLT script into HTML so that it looks pretty on the screen instead of collections of angled-bracketed data lumps.

So the transform only occurs when some browser looks at the file; any other program looking at the file will see only plain XML.

Can this be engineered?

Recent versions of Internet Explorer and Netccape/Mozilla can render XML contents with CSS or XSL stylesheets. So simply create an adequate stylesheet and put a reference to it in your XML documents. The documents will be nicely displayed in these browsers.
 

Nick Kew

Usenet Archive
Joined
Jul 21, 2000
Messages
292
Reaction score
0

rumionfire

Usenet Archive
Joined
Oct 20, 2004
Messages
16
Reaction score
0
No need for anything so heavyweight as cocoon. See for example

Yea there are many other lightweight solutions like AxKit, and other PHP based apps that can do the trasnformation. But they all require extra server component etc.

Using CSS to display the contents in a browser, does not require any serverside add-ons.

In Peace,
Saqib Ali
http://validate.sf.net
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,224
Members
248,132
Latest member
henrywalsh

Latest Threads

Top