Transform XML to HTML only for Browsers

Discussion in 'XML' started by Mungo Henning, Oct 20, 2004.

  1. 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
    Mungo Henning, Oct 20, 2004
    #1
    1. Advertising

  2. Mungo Henning

    Guest

    , Oct 21, 2004
    #2
    1. Advertising

  3. Mungo Henning

    Guest

    , Oct 21, 2004
    #3
  4. 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.)
    Johannes Koch, Oct 21, 2004
    #4
  5. 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
    Manuel Collado, Oct 21, 2004
    #5
  6. Mungo Henning

    Nick Kew Guest

    In article <>,
    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/
    Nick Kew, Oct 21, 2004
    #6
  7. Mungo Henning

    Guest

    > 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
    , Oct 21, 2004
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anthony Harkness-Gripe

    Dataset to XSL Transform not displaying HTML--only XML

    Anthony Harkness-Gripe, Aug 14, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    976
    itnrant
    Jul 8, 2008
  2. =?Utf-8?B?UnViZW4=?=

    Transform Word XML to HTML

    =?Utf-8?B?UnViZW4=?=, Mar 27, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    4,014
    =?Utf-8?B?UnViZW4=?=
    Mar 28, 2006
  3. Johannes Koch
    Replies:
    0
    Views:
    838
    Johannes Koch
    Jul 2, 2003
  4. Marrow
    Replies:
    0
    Views:
    4,127
    Marrow
    Jul 2, 2003
  5. El Kabong

    Browsers, browsers! Quo vadis?

    El Kabong, May 11, 2007, in forum: HTML
    Replies:
    23
    Views:
    873
    dorayme
    May 13, 2007
Loading...

Share This Page