Newbie question: why doesn't browser display xml source code as xhtml?

Discussion in 'XML' started by Guttyguppy, Sep 22, 2005.

  1. Guttyguppy

    Guttyguppy Guest

    Why is it when I open an xml file in a browser, I see the structure as
    defined in the xslt, but if I look at the source code I still see the
    xml? Shouldn't the xml be parsed into xhtml? Is there a way to do this
    (I'm sure there is, I'm just new to this stuff). Thanks for any info.
    Guttyguppy, Sep 22, 2005
    #1
    1. Advertising

  2. Guttyguppy wrote:

    > Why is it when I open an xml file in a browser, I see the structure as
    > defined in the xslt, but if I look at the source code I still see the
    > xml? Shouldn't the xml be parsed into xhtml?


    You asked to see the source, not the modified source.

    > Is there a way to do this (I'm sure there is, I'm just new to this stuff).


    Run it through an XSLT engine that outputs to a file rather then one that
    acts inside a browser.

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
    David Dorward, Sep 22, 2005
    #2
    1. Advertising

  3. Guttyguppy

    Guttyguppy Guest

    Thanks. Would the filter be running on the server then? What do people
    typically use?
    Guttyguppy, Sep 22, 2005
    #3
  4. Re: Newbie question: why doesn't browser display xml source codeas xhtml?

    Guttyguppy wrote:

    > Why is it when I open an xml file in a browser, I see the structure as
    > defined in the xslt, but if I look at the source code I still see the
    > xml? Shouldn't the xml be parsed into xhtml? Is there a way to do this
    > (I'm sure there is, I'm just new to this stuff).


    Well if you open such an XML document in IE/Win, in Mozilla or Firefox
    then the browsers uses an XML parser and an XSL(T) processor to
    transform the XML to HTML with script which displays the structure. So
    the XML is parsed and transformed to HTML which sounds what you want
    somehow ("shouldn't the xml parsed into xhtml").

    Of course you can write your own XSLT stylesheet and have such browsers
    use that stylesheet to do a different transformation, you simply need
    <?xml-stylesheet type="text/xsl" href="yourStylesheet.xml"?>
    as a processing instruction in the XML document.

    But as only a few browsers support client-side XSLT it is usually better
    to do XML to HTML transformation with XSLT on the server and serve HTML
    to the browser to render it.



    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Sep 22, 2005
    #4
  5. Guttyguppy

    Guttyguppy Guest

    Thanks again. What I mean is that I'm using Firefox 1.0.2 on OS 10.3.8
    and I'm opening my xml page which is linked to an xslt. It is formatted
    in the browser window. When I go to View Source, I'm expecting to see
    the <html>, <p>, <br/> tags, etc. but I just see the xml tags exactly
    as they look if I was to open the file in a text editor. I expect
    something like how php "spits out" html from the commands.
    Guttyguppy, Sep 22, 2005
    #5
  6. Guttyguppy

    Peter Flynn Guest

    Guttyguppy wrote:

    > Thanks again. What I mean is that I'm using Firefox 1.0.2 on OS 10.3.8
    > and I'm opening my xml page which is linked to an xslt. It is formatted
    > in the browser window. When I go to View Source, I'm expecting to see
    > the <html>, <p>, <br/> tags, etc. but I just see the xml tags exactly
    > as they look if I was to open the file in a text editor. I expect
    > something like how php "spits out" html from the commands.


    You only get that if the transformation is done on the server side.

    ///Peter
    Peter Flynn, Sep 22, 2005
    #6
  7. Guttyguppy

    Guttyguppy Guest

    I uploaded it to my server, and get the same thing going through http.
    Is there some kind of software that needs to run on the server?
    Guttyguppy, Sep 22, 2005
    #7
  8. Guttyguppy wrote:

    http://oakroadsystems.com/genl/unice.htm#googlefu

    > Thanks. Would the filter be running on the server then?


    If you just want to look at the output then you can run it on your
    workstation. The server is another option.

    > What do people typically use?


    I use the gnome libxslt library.

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
    David Dorward, Sep 22, 2005
    #8
  9. Guttyguppy

    Peter Flynn Guest

    Guttyguppy wrote:

    > I uploaded it to my server, and get the same thing going through http.
    > Is there some kind of software that needs to run on the server?


    Yes, you need an XML server like Axkit, Cocoon, or PropelX (and others).
    These contain engines which run the XSLT transformation from XML to
    HTML (or whatever) and serve it to the user.

    ///Peter
    Peter Flynn, Sep 23, 2005
    #9
  10. Guttyguppy

    Mislav Guest

    In Firefox, you can see the result of a transformation by inspecting
    the DOM with the built-in tool.

    For XSLT debugging do not rely on browsers - get your hands on a good
    XML editor like Oxygen where you can see all three stages of XSL
    Transformations in parallel panes
    Mislav, Sep 23, 2005
    #10
    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. marked
    Replies:
    7
    Views:
    560
    Daniel R. Tobias
    Sep 10, 2003
  2. gegan
    Replies:
    1
    Views:
    2,835
    Volkm@r
    Jul 25, 2005
  3. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    855
    Mark Rae
    Dec 21, 2006
  4. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,744
    Smokey Grindel
    Dec 2, 2006
  5. billium99

    ASP pages display source code in browser

    billium99, Aug 15, 2004, in forum: ASP General
    Replies:
    3
    Views:
    737
    Aaron [SQL Server MVP]
    Aug 15, 2004
Loading...

Share This Page