Styling in textual data via CSS and REST

Post here questions and problems related to oXygen frameworks/document types.
ArbitraryName
Posts: 16

Styling in textual data via CSS and REST

Tue Oct 21, 2014 1:54 am

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!
Radu
Posts: 5866

Re: Styling in textual data via CSS and REST

Tue Oct 21, 2014 9:05 am

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/#concepts/dg-xpath-function.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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
ArbitraryName
Posts: 16

Re: Styling in textual data via CSS and REST

Tue Oct 21, 2014 5:43 pm

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/#topics/api_faq_add_form_control_from_filter.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
Radu
Posts: 5866

Re: Styling in textual data via CSS and REST

Wed Oct 22, 2014 9:28 am

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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Return to “SDK-API, Frameworks - Document Types”

Who is online

Users browsing this forum: No registered users and 0 guests