Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Transform XML to HTML only for Browsers

Reply
Thread Tools

Transform XML to HTML only for Browsers

 
 
Mungo Henning
Guest
Posts: n/a
 
      10-20-2004
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
 
Reply With Quote
 
 
 
 
rumionfire@gmail.com
Guest
Posts: n/a
 
      10-21-2004
Using XSLTs to transform you XML to HTML will require a server side
engine like Cocoon to perform the transformation. You can instead
use a CSS to perform the transformation.

Here are some links with more information on this:

http://www.xml-dev.com/blog/#18
http://www.w3.org/TR/xml-stylesheet/

e.g.
http://unadorned.org/waspchump/xml/index.xml

In Peace
Saqib Ali
http://validate.sf.net
 
Reply With Quote
 
 
 
 
rumionfire@gmail.com
Guest
Posts: n/a
 
      10-21-2004
one more interesting site:

http://www.badgers-in-foil.co.uk/projects/docbook-css/

In Peace,
Saqib Ali
http://validate.sf.net
 
Reply With Quote
 
Johannes Koch
Guest
Posts: n/a
 
      10-21-2004
Mungo Henning wrote:
> 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.
--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
 
Reply With Quote
 
Manuel Collado
Guest
Posts: n/a
 
      10-21-2004
Mungo Henning wrote:

> 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.
--
To reply by e-mail, please remove the extra dot
in the given address: m.collado -> mcollado

 
Reply With Quote
 
Nick Kew
Guest
Posts: n/a
 
      10-21-2004
In article <(E-Mail Removed)> ,
http://www.velocityreviews.com/forums/(E-Mail Removed) writes:
> Using XSLTs to transform you XML to HTML will require a server side
> engine like Cocoon to perform the transformation.


No need for anything so heavyweight as cocoon. See for example
http://www.outoforder.cc/projects/apache/mod_transform/

I offer users choice of format for XML reports. So
http://my.server/reports/foobar <=== raw XML
http://my.server/reports/foobar.html <=== HTML for browsers
http://my.server/reports/foobar.rdf <=== semweb

--
Nick Kew

Nick's manifesto: http://www.htmlhelp.com/~nick/
 
Reply With Quote
 
rumionfire@gmail.com
Guest
Posts: n/a
 
      10-21-2004
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dataset to XSL Transform not displaying HTML--only XML Anthony Harkness-Gripe ASP .Net 1 07-08-2008 01:23 AM
Browsers, browsers! Quo vadis? El Kabong HTML 23 05-13-2007 08:55 PM
Transform Word XML to HTML =?Utf-8?B?UnViZW4=?= ASP .Net 2 03-28-2006 07:03 PM
Two Browsers work! Two browsers won't load. Internet game service won't load jimmie Computer Support 1 02-26-2006 08:36 AM
blocking I/O with javax.xml.parsers.DocumentBuilder.parse() and javax.xml.transform.Transformer.transform() jazzdman@gmail.com Java 1 03-27-2005 06:56 AM



Advertisments