executing XPath after XInclude

Oxygen general issues.
avanlooveren
Posts: 26
Joined: Wed Jun 26, 2013 1:08 am

executing XPath after XInclude

Post by avanlooveren »

I have elements that I want to style in Author depending on contextual information. For this, I figured that I would use oxy_xpath() to perform a test that, importantly, grabs information (an attribute) from the parent element. This works until I XInclude the content. I checked the forum, and I see a few posts related to this issue:
So, my question is, how do I get XIncluded content to be styled with rules that are described most easily (flexibly and consistently) with XPath? For instance, let's say I want to do this:

Code: Select all

myChildElement {
border-color: oxy_xpath("if (@childId = ../@specialChildId) then 'yellow' else 'black'"));
}
alex_jitianu
Posts: 1007
Joined: Wed Nov 16, 2005 11:11 am

Re: executing XPath after XInclude

Post by alex_jitianu »

Hello,

The oxy_xpath function doesn't go into XInclude content so as you discovered you can't use it for elements from inside the XInclude.

First you should check the supported CSS selectors just in case you can express the condition just by selector alone. For example, assuming you already know the value of the attributes (which considering they are IDs I doubt that you do) you could write:

Code: Select all


*[specialChildId="my_value"] > myChildElement[childId="my_value"] {
border-color:yellow;
}
If the CSS selectors are not enough and you don't mind going into the Java based API, you can implement a ro.sync.ecss.extensions.api.StylesFilter. In this filter you can inspect the parent elements and check the attributes etc and if certain conditions met you can add new styles on the element. Here is a topic that describes how to implement such an extension point: http://www.oxygenxml.com/doc/ug-editor/ ... ilter.html.

Best regards,
Alex
alex_jitianu
Posts: 1007
Joined: Wed Nov 16, 2005 11:11 am

Re: executing XPath after XInclude

Post by alex_jitianu »

Hi,

For future reference, starting with version 17.1, oxy_xpath() also expands XIncludes.

Best regards,
Alex
Post Reply