Page 1 of 1

Styling in textual data via CSS and REST

Posted: Tue Oct 21, 2014 1:54 am
by ArbitraryName
Hello,

We have been leveraging the binary content styling for images quite heavily and it has been very useful.

We are now hoping there is a CSS call which will allow us to contact a restful webservice to get back some information, and then seed that into our author views.

Is there a way, similar to oxy_url to resolve textual data?

Or is it possible to create our own extension for th CSS to call? Like my_text_url("blah").


Thanks a million everyone, these forums are great!

Re: Styling in textual data via CSS and REST

Posted: Tue Oct 21, 2014 9:05 am
by Radu
Hi,

I do not quite understand your use case. Where in the Author view would you like to display that information obtained from the REST service?

One solution would be to use our oxy_xpath CSS function:

http://www.oxygenxml.com/doc/ug-oxygen/ ... ction.html

which can be used to executed xpaths which use the document function to parse an XML from a remote server and then gather information from it.

Or you could use our Java ro.sync.ecss.extensions.api.StylesFilter API to implement your own Java code which adds additional CSS styling to certain nodes by contacting a server for example.

Regards,
Radu

Re: Styling in textual data via CSS and REST

Posted: Tue Oct 21, 2014 5:43 pm
by ArbitraryName
Ok awesome; both of those seem like feasible solutions.

To clear up our use case, our XML has a UUID which also has a name. However, those names can change outside of the XML, so we want to 'resolve' the UUID into the name and then display those to the author.

The second option, where we implement our own StylesFilter, would that be the best option? It seems very similar to the example detailed here http://www.oxygenxml.com/doc/ug-oxygen/ ... ilter.html.

We quickly tried the first option with xpath but it seemed to fail. We used this:

oxy_xpath("document('http://ourservice.com/ID')/root/title/text()");

But we got this error back: [CSS]:XPath failed: XPath failed due to: System function document#1 is not available with this host language/version

Was there something else you meant for us to do? Or should that have worked?

Thanks a lot Radu!

AN

Re: Styling in textual data via CSS and REST

Posted: Wed Oct 22, 2014 9:28 am
by Radu
Hi,

For the oxy_xpath approach you should use the doc function (and not document as I previously said) like:

Code: Select all

oxy_xpath("doc('http://ourservice.com/ID')/root/title/text()")
The document function is XSLT specific and cannot be used in a plain XPath execution.

For the styles filter approach, the topic you found gathers a list of values for a form control embedded in the Author editing mode. If you choose this approach, you should know that the styles filter is called very often so you need to cache results and avoid running a query on the server for each callback.

Regards,
Radu