StyleSheetExtension SSX not parsed

I made a style sheet extension with following code:

#if($doc.getExternalURL().contains('rubbish.example.org'))
#companylogo::after {
    content: "Spielwiki";
}
#elseif($doc.getExternalURL().contains('test.example.org'))
#companylogo::after {
    content: "Testwiki";
}
#else
#companylogo::after {
    content: "";
}
#end

I set:

  • use: in this wiki
  • parse: yes
  • cache: standard
  • type: css

It’s not working. And if I look at the css “file” beautified I see:

#if($doc.getExternalURL().contains('rubbish.example.org')) #companylogo::after {
    content: "Spielwiki"
}

#elseif($doc.getExternalURL().contains('test.example.org')) #companylogo::after {
    content: "Testwiki"
}

#else #companylogo::after {
    content: ""
}

#end

There is no difference in this css “file” whether I switch parse on or off.

This happens at:

  • XWiki Jetty HSQLDB 13.1
  • XWiki Debian 13.10.1

Any ideas?
Regards, Simpel

Hello @Simpel,

I did a try a got the expected result with the same configuration as you.

One small improvement you can do is to escape the # used in the css id selectors, since otherwise if a macro with the same name exists, it will be called instead (see the example below).

Calling http://localhost:8082/xwiki/bin/ssx/TestCSS/WebHome returns #companylogo::after{content:""} (given that the StyleSheetExtension is located at TestCSS.WebHome).

One thing you can do to find what’s going wrong in you instance is check you logs, if something goes wrong with velocity interpretation, a warning will be logged.

#set( $H = '#' )
#if($doc.getExternalURL().contains('rubbish.example.org'))
${H}companylogo::after {
    content: "Spielwiki";
}
#elseif($doc.getExternalURL().contains('test.example.org'))
${H}companylogo::after {
    content: "Testwiki";
}
#else
${H}companylogo::after {
    content: "";
}
#end

Hope that helps.

Hi.
I tried your trick, but this wouldn’t be parsed too.
Our wiki language is set to german. Maybe there is a difference? But not very likely.

If I put this code into a pure article (with {{velocity}} around it) then it will be parsed. I then only see that part of css that should be used.

Found a warning in the log:

WARN c.x.x.w.s.SxDocumentSource - Velocity errors while parsing skin extension [xwiki:Macros und Plugins.NDR-Theme-Style.WebHome] with content [

Not very helpful?

To be precise, there were nearly 900 lines of css before. And I found that one line with the error.
The following comment line made velocity not parse correctly:

/* NOPRINT für #hierarchy (Breadcrumbs); .menu-horizontal-toggle (Mainmenu); #xdocFooter, #xwikidata (Likes, Kommentare etc.) */

As I removed parentheses and wrote it this way it worked:

/* NOPRINT für #hierarchy <Breadcrumbs>, .menu-horizontal-toggle <Mainmenu>, #xdocFooter, #xwikidata <Likes, Kommentare etc.> */