Page 1 of 1

Use oxy_xpath with oxy_add?

Posted: Wed Nov 30, 2011 6:00 pm
by JamesL
I am attempting to use oxy_add in a custom CSS for the Author mode, which works fine. But the catch is I want to use oxy_xpath to return a number for one or two of the input parameters.

I have constructed the following:

oxy_add(oxy_xpath("./path/to/node/number()"),1, number)

This works in that the number is calculated correctly, but I am getting errors in the console as follows:
System ID: /Applications/author/modified_frameworks/dita/css_classed/dita.css
Severity: error
Description: [CSS]:Invalid "oxy_add" function signature. Must be "oxy_add"(param1, param2, ..., 'returnType')
Allowed values for the return type: ('integer', 'number', 'px', 'pt', etc).
Example:
width: oxy_add(attr(size), 10, 'px')
Could not convert the 1 argument to a float value.
I suspect it is pointing to the dita.css because that is where my custom CSS is imported at.

Any suggestions? Even though the oxy_add is working, I do not want to deploy it to end users with the console spitting out errors.

Thanks.

Re: Use oxy_xpath with oxy_add?

Posted: Thu Dec 01, 2011 9:48 am
by Radu
Hi James,

Basically Oxygen evaluates the XPath expression in two different stages, one when the document is just being built and the expression might not match (because the target nodes might not exist) and one final stage when the document is fully built.
We'll try to make some improvements to avoid reporting such problems in the initial stage.
In the meantime, Oxygen fully supports XPath 2.0 expressions so you can have if conditional processing in it like:

Code: Select all

*[audience]:before{
content:oxy_add(oxy_xpath("if(count(@audience) > 0) then @audience else '0'"),1, number);
}
This will help you give a fallback value from the XPath expression and avoid the warning.
We'll update this forum post when we find a fix for the original problem.

Regards,
Radu

Re: Use oxy_xpath with oxy_add?

Posted: Thu Dec 01, 2011 4:41 pm
by JamesL
Adding the if statements did the trick, I no longer get the error messages.

It is odd though, because the nodes that I am using must be present, as they are mandated by the DTD.

Thank you for the help!

Re: Use oxy_xpath with oxy_add?

Posted: Thu Dec 01, 2011 4:46 pm
by Radu
Hi,

The first time that the XPath expression gets executed by our internal code, not all the XML document has loaded and the XML is in an inconsistent state.
We fixed this and in Oxygen 13.2 (in January 2012) your first proposed selector will work as well.

Regards,
Radu

Re: Use oxy_xpath with oxy_add?

Posted: Thu Dec 01, 2011 7:39 pm
by JamesL
Makes sense.

Thank you again for the quick help.