Jump to content

cant see css file


xmlxpert

Recommended Posts

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...