format-date(current-date()) problem

Having trouble installing Oxygen PDF Chemistry? Got a bug to report? Post it all here.
Stanislav
Posts: 10
Joined: Thu Aug 30, 2018 7:25 pm

format-date(current-date()) problem

Post by Stanislav »

Hello!

I'm trying to set the 'current-date' string at the title page for displaying the current date by using 'ru' localization. But something work wrong. when the compilation of pdf is completed, this line is displayed '[Language: en] August 2018'. In default parameters with no locale argument ('en' language is default) there are no problems.

code is shown below:
....
*[class ~= "bookmap/booktitle"]:after(2) {
display:block;
content: oxy_xpath("format-date(current-date(), '[MNn] [Y0001]' "ru", (), ())");
....

Initial data are as follows:
The latest version of OxygenXML + chemistry, the compiler via DITA Map PDF is based on DITA & CSS (WYSIWYG) + own css.

Who faced this problem? Any help will be pleasure.
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Re: format-date(current-date()) problem

Post by Dan »

There is a syntax error in your XPath expression, it misses a comma and you should use singe quotes around the 'ru' token, since the entire expression is already enclosed in double quotes:

The correct form is:

Code: Select all


...
content: oxy_xpath("format-date(current-date(), '[MNn] [Y0001]', 'ru', (), ())");
...
Please use the XPath builder view from oXygen when developing XPath expressions.

Best regards,
Dan
Stanislav
Posts: 10
Joined: Thu Aug 30, 2018 7:25 pm

Re: format-date(current-date()) problem

Post by Stanislav »

Dan wrote:There is a syntax error in your XPath expression, it misses a comma and you should use singe quotes around the 'ru' token, since the entire expression is already enclosed in double quotes:

The correct form is:

Code: Select all


...
content: oxy_xpath("format-date(current-date(), '[MNn] [Y0001]', 'ru', (), ())");
...
Please use the XPath builder view from oXygen when developing XPath expressions.

Best regards,
Dan
Thanks for answer Dan!
It's my mistake in this example with double quotes, in my code is all ok with syntax. But this does not work with single quotes.
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Re: format-date(current-date()) problem

Post by Dan »

Yes, indeed, I tested the expression using the Saxon SA XPath processor, while the Chemistry distribution contains Saxon HE. I will check what happens.

Thank you for the feedback!
Dan
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Re: format-date(current-date()) problem

Post by Dan »

It looks like Saxon HE is limited by design: https://sourceforge.net/p/saxon/mailman ... /26849522/
The only workaround is to format the date like this:

Code: Select all


...
content: oxy_xpath("let $cm:= format-date(current-date(), '[MNn]') \
return concat( \
if ($cm= 'January') then 'JAN' else \
if ($cm= 'February') then 'FEB' else \
if ($cm= 'March') then 'MAR' else \
if ($cm= 'April') then 'APR' else \
if ($cm= 'May') then 'MAY' else \
if ($cm= 'June') then 'JUNE' else \
if ($cm= 'July') then 'JUL' else \
if ($cm= 'August') then 'AUG' else \
if ($cm= 'September') then 'SEPT' else \
if ($cm= 'October') then 'OCT' else \
if ($cm= 'November') then 'NOV' else '' \
, \
' ', \
format-date(current-date(), '[Y0001]') \
) ");
...
Make sure the entire expression is rendered blue in the CSS editor. Replace the caps with the Russian month names.

Best regards,
Dan
Stanislav
Posts: 10
Joined: Thu Aug 30, 2018 7:25 pm

Re: format-date(current-date()) problem

Post by Stanislav »

Dan wrote:It looks like Saxon HE is limited by design: https://sourceforge.net/p/saxon/mailman ... /26849522/
The only workaround is to format the date like this:

Code: Select all


...
content: oxy_xpath("let $cm:= format-date(current-date(), '[MNn]') \
return concat( \
if ($cm= 'January') then 'JAN' else \
if ($cm= 'February') then 'FEB' else \
if ($cm= 'March') then 'MAR' else \
if ($cm= 'April') then 'APR' else \
if ($cm= 'May') then 'MAY' else \
if ($cm= 'June') then 'JUNE' else \
if ($cm= 'July') then 'JUL' else \
if ($cm= 'August') then 'AUG' else \
if ($cm= 'September') then 'SEPT' else \
if ($cm= 'October') then 'OCT' else \
if ($cm= 'November') then 'NOV' else '' \
, \
' ', \
format-date(current-date(), '[Y0001]') \
) ");
...
Make sure the entire expression is rendered blue in the CSS editor. Replace the caps with the Russian month names.

Best regards,
Dan
It works, it works!!!! Amazing!
Thanks a lot, you are best!
Post Reply