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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With