Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any language syntax for cascading data other than style?

Tags:

While CSS could only set styling and mainly used with HTML. I think it should be possible to use a concept of selector and cascading to apply value to xml attribute

Is there any standardized or proposed syntax for this kind of concept?

like image 542
Thaina Yu Avatar asked Oct 10 '19 15:10

Thaina Yu


1 Answers

It sounds like you're imagining one file which contains an XML document, and another file which contains blocks of properties with values, each block starting with a "selector" of some sort which defines to which XML elements those properties apply (much like CSS, potentially even using the same syntax). Then you are imagining a process which transforms the XML document by modifying the selected XML elements' attributes based on the properties declared for that selector.

The general concept of transforming XML based on a supplementary ruleset is called Extensible Stylesheet Language Transformation (XSLT).

More specifically related to defining properties with selectors and a CSS-like syntax, the World Wide Web Consortium has published "Associating Style Sheets with XML documents", a W3C Recommendation, in 2010. This document provides recommendations to software developers who are performing XSLT for XML and wish to associate CSS-syntax properties which affect the transformation of elements to whom the selector applies.

The application which is consuming the XML is responsible for implementing support for XML stylesheets in this manner -- it is not a core part of the language. Most modern web browsers can perform XML-to-HTML XSLT and many support XML-stylesheets using the syntax described in the W3C recommendation above. For a similar reason, CSS can also be applied directly to SVG files (which is an XML format) when rendered in the browser.

When working with generic XML, rather than XHTML, the recommended syntax is much simpler, with only rudimentary support for selectors.

The W3C guidelines could be applied to use a CSS-like syntax to define properties applied to selected elements in an XML document, and then implement transformations based on those properties to affect the final XML however you desire. Some XML libraries, especial XSLT implementations, may provide extensible mechanisms to make this easier, but ultimately you will need to implement the transformations yourself.

like image 166
Woodrow Barlow Avatar answered Oct 03 '22 17:10

Woodrow Barlow