Adding a CSS stylesheet to xml

Here should go questions about transforming XML with XSLT and FOP.
felix1845
Posts: 10
Joined: Mon May 29, 2017 7:19 pm

Adding a CSS stylesheet to xml

Post by felix1845 » Sun Jun 04, 2017 3:25 am

I am very confused about using a css stylesheet to alter the formatting of xml in a browser. I have an xslt stylesheet, and that works fine, but the css doesn't appear to make any difference.

At the top I have <?xml-stylesheet href="text.css" type="text/css"?>. Is this wrong? The css file is called "text.css".

I know there have been posts on this before, but I've read them and can't make sense of them.

Radu
Posts: 6541
Joined: Fri Jul 09, 2004 5:18 pm

Re: Adding a CSS stylesheet to xml

Post by Radu » Mon Jun 05, 2017 8:02 am

Hi,

If you open an XML document with an associated CSS in a web browser, the CSS selectors must match those particular XML elements and style them. So you cannot have the CSS match HTML element names, they need to match the XML element names as you have not converted the XML to HTML.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply