Page 1 of 1

oxy_* functions and maptitle variable not working in CSS @page scope?

Posted: Tue Nov 25, 2025 6:13 pm
by Vinny
Folks,
I’m trying to split the ‘Title’ of a document to have it printed on two lines in the footer (PDF/CSS transform). For example, my title could be ‘Sample Document $ Rev. 1' and in the footer I'd like to have 'Sample Document' printed above 'Rev. 1', using '$' as a separator for the two lines.
So I set out writing a first CSS draft rule like this:

Code: Select all

@page :right {
	[…]
	@bottom-right {
       		content: oxy_substring(string(maptitle), 0, oxy_indexof(string(maptitle), "$"));
       	}
}
This would of course display only the first part, but, the result is stubbornly void. This doesn’t return anything, although the ‘maptitle’ variable is correctly set, since:

Code: Select all

	content: string(maptitle);
works perfectly well.
Also, this code:

Code: Select all

	content: oxy_indexof(string(maptitle),"$");
displays '-1' in the footer, as if the string was empty or not defined. I've tried other characters instead of '$', to no avail.
However,

Code: Select all

	content: oxy_indexof("abc@abc", "@");
Correctly outputs 3. So something is wrong, as if maptitle wasn't set when the CSS rule is evaluated.
Any clue to what I did wrong or workaround?

EDIT: This works fine, is maybe simpler?

Code: Select all

       content: oxy_xpath('substring-before(//head/title/text(), "|")')
                 "\0A"
                 oxy_xpath('substring-after(//head/title/text(), "|")');

Re: oxy_* functions and maptitle variable not working in CSS @page scope?

Posted: Wed Nov 26, 2025 2:39 pm
by julien_lacour
Hello,

The issue is that string() CSS function is evaluated per page for margin boxes, so its value is only available at page generation time and cannot be used as a parameter in an oxy function.
Instead you could use oxy_xpath() and create a new string-set (keep the original maptitle or it will be overriden by the custom definition):

Code: Select all

*[class ~= "front-page/front-page-title"] > *[class ~= "topic/title"] {
  string-set: maptitle content(), 
custommaptitle oxy_xpath("if (contains(text(), '$')) then replace(text(), '\\$', '\0A') else text()");
}
@page :right {
  @bottom-right {
    content: string(custommaptitle);
  }
}

Regards,
Julien