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

G

Guttyguppy

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.
 
D

David Dorward

Guttyguppy said:
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.
 
G

Guttyguppy

Thanks. Would the filter be running on the server then? What do people
typically use?
 
M

Martin Honnen

Guttyguppy said:
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.
 
G

Guttyguppy

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.
 
P

Peter Flynn

Guttyguppy said:
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
 
G

Guttyguppy

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?
 
P

Peter Flynn

Guttyguppy said:
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
 
M

Mislav

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
 

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

Members online

Forum statistics

Threads
473,999
Messages
2,570,244
Members
46,838
Latest member
KandiceChi

Latest Threads

Top