Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / CSS / December 2003



Tip: Looking for answers? Try searching our database.

XML and CSS

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Neil Zanella - 27 Dec 2003 04:28 GMT
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
Jukka K. Korpela - 27 Dec 2003 09:00 GMT
> 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.)

Signature

Yucca, http://www.cs.tut.fi/~jkorpela/

JustAnotherGuy - 27 Dec 2003 21:42 GMT
> 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.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.