4 ms·
> I remember you could point to a stylesheet to apply to an XML file. You still can. That's exactly what this article is about: XSLT is that stylesheet. You
by Telemakhos 1y ago
> I remember you could point to a stylesheet to apply to an XML file.
You still can. That's exactly what this article is about: XSLT is that stylesheet. You can publish XML-structured data that machines can ingest, and you can attach XSLT to that data so that humans can view the exact same file in a human-friendly way. The browser constructs, according to the XSL transform rules, a Document Object Model out of the XML, and then it usually applies CSS to that DOM. No duplication of files, no "click here to get to the actual data." I've got some OPML (lists of podcasts) and RSS (podcast) XML files that are also human-readable web pages thanks to this; the exact same web address works for your favorite podcast app and for human viewing.
> I really wish we could apply CSS stylesheets to a JSON.
I don't think what you want is CSS in the first instance, but in the second: first you'd want a template transformation language like XLST is for XML. You'd want to be able to say not just "show these values in this font" but "for each key matching this pattern, create a DOM element containing that key, then another element containing its value," and then style them with CSS when a whole document has been generated out of the JSON. XML with XSLT almost always also included CSS to handle fonts and whatnot.
- sunshine-o 1y agoOh no you can apply a CSS directly to XML https://www.w3.org/Style/styling-XML.en.html https://www.w3.org/Style/styling-XML.en.html It is simple and works very well for simple documents. Remember, XHTML was just an XML document.