executing XPath after XInclude

<oXygen/> general issues.
avanlooveren
Posts: 25

executing XPath after XInclude

Mon Jul 15, 2013 11:17 pm

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: 604

Re: executing XPath after XInclude

Tue Jul 16, 2013 10:53 am

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/#topics/dg-author-css-styles-filter.html.

Best regards,
Alex
alex_jitianu
Posts: 604

Re: executing XPath after XInclude

Wed Dec 28, 2016 12:13 pm

Hi,

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

Best regards,
Alex

Return to “Other Issues”

Who is online

Users browsing this forum: No registered users and 1 guest