Search
The Caboteria
/
Tech Web
/
XmlXslCssExperiment
(01 Jan 2004,
TobyCabot
)
(raw view)
_(Main.TobyCabot - 12 Nov 2003)_ We found out from the XmlCssExperiment that we can't expect to send XML and CSS to browsers and get good cross-browser results. Mozilla does a pretty good job, but IE doesn't. There's another approach, though: send an XML document with a link to an XSL stylesheet. The stylesheet transforms the XML document into HTML which the browsers seem to be better at displaying than raw XML. Here's a document that includes a link to an XSL stylesheet: <verbatim> <?xml version="1.0" ?> <?xml-stylesheet type="text/xsl" href="trivial.xsl" ?> <body> This is an XML document. It's well-formed but doesn't have a DTD so we can't say if it's valid or not. It also has a processing instruction that tells the browser how to find an XSL stylesheet with instructions how to transform the document into HTML. </body> </verbatim> The =xml-stylesheet= processing instruction tells the browser where to look for the stylesheet, which is a little more complex (since XSLT is pretty complex): <verbatim> <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <!-- The overall structure of a page --> <html> <head> <title>Sample XML/XSL Page</title> </head> <body> <xsl:value-of select="body" /> </body> </html> </xsl:template> <xsl:template match="hidden" /> </xsl:stylesheet> </verbatim> You can see the [[http://www.caboteria.org/~tobyc/example/trivial-xsl.xml][result here]], it's pretty plain. We can spruce it up by adding a link to a CSS stylesheet, in this case using the same link that you'd use in a regular HTML page. <verbatim> ... <head> <title>Sample XML/XSL/CSS Page</title> <link rel="stylesheet" type="text/css" href="trivial.css"/> </head> ... </verbatim> You can see the [[http://www.caboteria.org/~tobyc/example/trivial-xsl-css.xml][result here]].
E
dit
|
A
ttach
|
P
rint version
|
H
istory
: r2
<
r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding The Caboteria?
Send feedback