By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,739 Members | 1,081 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,739 IT Pros & Developers. It's quick & easy.

XML and CSS

P: n/a
Hello,

Could someone please give me an example of how to use CSS to define
the rendering of an XML document (as opposed to an ordinary XHTML
document). That is, the document must contain some custom tags.
Do any web browsers currently support the rendering of arbitrary
XML documents using CSS?

Thanks,

Neil
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
nz******@cs.mun.ca (Neil Zanella) wrote:
Could someone please give me an example of how to use CSS to define
the rendering of an XML document (as opposed to an ordinary XHTML
document).
an .xml document, to be served as text/xml:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="cool.css"?>
<document>
<heading>XML+CSS demo</heading>
<paragraph>This is a <cool>simple</cool> test.</paragraph>
</document>

a .css document, to be served as text/css:

heading, paragraph { display: block; }
heading { font-size: 130%; margin-bottom: 1em; }
cool { font-style: italic; }
That is, the document must contain some custom tags.
Oh. Between the lines, I read that you would like to scatter around a
few homebrew tags into an HTML document and "define" their rendering in
CSS, presumably not considering what happens in non-CSS rendering.
In theory, advertizing the document as aprilcation... sorry
application/xhtml+xml would ask the browser do that, i.e. render the
document's HTML constructs as usual and accept some extra tags and play
with them by your CSS rules. This won't work well on the WWW since
IE completely fails to make any sense of that media type.
Do any web browsers currently support the rendering of arbitrary
XML documents using CSS?


Most modern graphic browsers do. What you lose is the universality of
HTML. For example, even if you wrote an aural style sheet (did you even
think of that?), there's probably not a single speech browser that
would render the document according to it - instead, they would not
render the XML document at all, or would render it by reading the
markup.

And users will not be able to switch off CSS (without a style sheet, an
XML document cannot really be rendered at all), or to have their user
style sheet participate in the cascade. In a word, from the user's
point of view, you would be decades back, in the bad old days when
documents were formatted for a single rendering situation.

So it's a much better approach (at present at least) to use good old
HTML, or XHTML if you wish to be illusioned into thinking it's better
because it's newer and the Latest Recommendation, and express the extra
markup using classes rather than tags. That is, instead of
<cool>...</cool> you would write <span class="cool">...</span>.
You will have the same problem with non-CSS rendering, but at least the
Market Leader will do something meaningful with your soup. Besides, if
you take some care and pay attention to what happens when CSS is not in
use, it might work just fine.

(You would naturally use <div class="...">...</div> for constructs that
should be rendered as blocks and not inline.)

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Jul 20 '05 #2

P: n/a
Jukka K. Korpela wrote:
So it's a much better approach (at present at least) to use good old
HTML, or XHTML if you wish to be illusioned into thinking it's better
because it's newer and the Latest Recommendation


Sounds like an argument bandied about by the "why css" crowd as well...?
I mean, you might as well close some tags if it's going to future-proof
your work.

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.