Go Back   SitePoint Forums > Forum Index > Program Your Site > XML and Web Services
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Dec 4, 2007, 09:58   #1
willroads
SitePoint Member
 
Join Date: Dec 2007
Posts: 2
creating a .css file for xml

q

Last edited by willroads; Dec 11, 2007 at 06:52.
willroads is offline   Reply With Quote
Old Dec 4, 2007, 10:39   #2
wwb_99
Community Advisor
silver trophybronze trophy
 
wwb_99's Avatar
 
Join Date: May 2003
Location: Washington, DC
Posts: 9,260
What you need to do is use XSL to transform the XML data into HTML that a browser can handle. Then all the normal CSS stuff is avaliable for your use.
wwb_99 is offline   Reply With Quote
Old Dec 4, 2007, 11:16   #3
brandaggio
Brevity is greatly overrated
 
brandaggio's Avatar
 
Join Date: Dec 2005
Posts: 1,427
Quote:
Originally Posted by willroads View Post
Basically I am making a xhtml music player, with iframes to display albums and songs etx.
My first problem is that I cannot make a .css file for the iframe to understand the xml file, i just get the error:

This XML file does not appear to have any style information associated with it. The document tree is shown below.

How can I fix this? Thank you very much, Will
You can indeed actually style XML directly with CSS, however it behaves differently than (X)HTML which already has some base CSS applied - XML has zero style by default - more like HTML with a CSS "super-duper" global reset applied.

Of course, the first thing you need to to is make sure you have complete (DTD etc.) and properly marked up page/s so the browser/s doesn't choke - a typical XML parser is pretty unforgiving.

Further, in the context you have with the iframe and whatnot I am not sure it would/will work and then you have the issue of browser support for XML (which isn't that bad actually). So you may or may not have some success given the browsers you intend to support (there is always THE problem child browser to deal with) and the compromises you are willing to make. Certainly at least worth tinkering with.

Saxon is probably the easiest way to get up and running with XSLT, should you want to transform your XML to (X)HTML first and then apply the CSS to it.
brandaggio is offline   Reply With Quote
Old Dec 4, 2007, 12:25   #4
willroads
SitePoint Member
 
Join Date: Dec 2007
Posts: 2
s

Last edited by willroads; Dec 11, 2007 at 06:53.
willroads is offline   Reply With Quote
Old Dec 5, 2007, 06:10   #5
kgun
SitePoint Addict
 
Join Date: Nov 2005
Location: Moss, Norway.
Posts: 280
Note, there is (was at least not in XSLT 1.0) an output XHTML method in XSLT. But since, XHTML has to be well-formed XML, you can use XML as the output method for XHTML. That is, you can define the style sheet element like this:
Code:
<xsl:stylesheet version='1.0'
xmlns:xsl="http://w3.org/1999/XSL/Transform"
xmlns="http://w3.org/1999/xhtml"> // (Default name space.  I don't like it, so you you may prefix it with your own QName).

<xsl:output method="xml" ...  />

</xsl:stylesheet>
There is nothing new when styling XML elements compared to styling HTML elements with CSS.
kgun is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 19:25.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved