How to change css style information dynamically within a macro

I would like to dynamically change style specifications in the “HEAD-section” - especially for @media print.

My solution is based on the following basic specification, here as an example (“ipsum” turns red)

{{velocity}}
#set ($discard=$xwiki.linkx.use("data:text/css, .democlass {background-color:orange}",{'type': 'text/css', 'rel': 'stylesheet'}))
{{/velocity}}
Lorem (% class="democlass" %) ipsum (%%) dolor sit

In this procedure, I can dynamically create the specification behind “data:” within a macro.
I want to avoid creating or changing a large number of XWiki.StyleSheetExtension objects.

Comments, especially suggestions for improvement are very welcome.

Norbert

Hi. I don’t know if this can help you but you can also change the head section by editing the “HTTP META INFO” part of https://extensions.xwiki.org/xwiki/bin/view/Extension/Administration%20Application#HPresentation

PS: When creating forum post, please select the forum category (“Help/Discuss” ). Thanks!