xmlxpert Posted February 20, 2006 Share Posted February 20, 2006 hi, Im a newbie and wondering why the xml file cant see the css file? I actually got this code on w3schools tutorial about xml-css but seems like it wont work on me. I got 3 files ;default.htm(embeded the xml file), cd_catalog.xml and cd_catalog.cssThe output was the content of the cd_catalog.xml with the css file in which I made reference with but same old same the code on cd_catalog.css wasnt implemented.1.) default.htm <html><body><xml id="cdcat" src="cd_catalog.xml"></xml><table border="1" datasrc="#cdcat"><tr><td><span datafld="ARTIST"></span></td><td><span datafld="TITLE"></span></td></tr></table></body></html> 2.) cd_catalog.xml <?xml version="1.0" encoding="ISO-8859-1"?><!-- Edited with XML Spy v4.2 --><?xml-stylesheet type="text/css" href="cd_catalog.css"?><CATALOG> <CD> <TITLE>Empire Burlesque</TITLE> <ARTIST>Bob Dylan</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Columbia</COMPANY> <PRICE>10.90</PRICE> <YEAR>1985</YEAR> </CD> <CD> <TITLE>Hide your heart</TITLE> <ARTIST>Bonnie Tyler</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>CBS Records</COMPANY> <PRICE>9.90</PRICE> <YEAR>1988</YEAR> </CD></CATALOG> 3.) cd_catalog.css CATALOG{background-color: #ffffff;width: 100%;}CD{display: block;margin-bottom: 30pt;margin-left: 0;}TITLE{color: #FF0000;font-size: 20pt;}ARTIST{color: #0000FF;font-size: 20pt;}country, price, year, company{display: block;color: #000000;margin-left: 20pt;} Link to comment Share on other sites More sharing options...
DarkElf Posted February 20, 2006 Share Posted February 20, 2006 I'm not very experienced with xml but the problem looks to me like thus:If you are referencing an external css file you do so in the head section of the html document, you are referencing it via the xml document which is included in the body section of the html. I may be wrong as I've not done much with xml before though.You could try referencing the css in the head of the html document, and then applying it to the xml element by giving it a relevant class or id. Try it and see if it works. Link to comment Share on other sites More sharing options...
xmlxpert Posted February 20, 2006 Author Share Posted February 20, 2006 Hi, actually it works when you reference it in the head of an html doc but it is also possible to reference a css file within an xml file from what the w3c have said so. anyways Thanks on replying DarkElf, thanks Link to comment Share on other sites More sharing options...
DarkElf Posted February 20, 2006 Share Posted February 20, 2006 In which case I don't know what is wrong, but I think my suggestion might still work. Reference the css in the header and then give the xml element a relevant class/id so the correct formatting is applied. Link to comment Share on other sites More sharing options...
boen_robot Posted February 20, 2006 Share Posted February 20, 2006 DataIslands and XML with CSS are two completely separated ways of styling XML data.Embeding XML data with DataIslands(the <xml> tag) means to "bind" the ata inside the XHTML. It doesn't refer to styling it. The CSS file for the XHTML has "the honor" of styling the displayed data inside the XHTML page. Of course, this works only with IE but that's another subject.To style an XML with CSS means to style the XML file itself. This means that it will all be effective when the XML file is ran in the browser. Different transformations of the same document will apply their own respective styles.The fact that CSS styling in XML can't be carried to the XHTML page is the reason why CSS styling was never the future of XML styling. The best method is an XSLT page that would have a reference to external stylesheet that would style the transformed document. Link to comment Share on other sites More sharing options...
xmlxpert Posted February 21, 2006 Author Share Posted February 21, 2006 Hi, Oh I see now, thanks robot, I'll do the xsl then. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now