Custom functions in CSS oxy_url()
-
- Posts: 72
- Joined: Thu Mar 26, 2015 4:57 pm
Custom functions in CSS oxy_url()
Post by steve.cuzner »
Code: Select all
function resolvehref(href) {
return "http://www.google.com";
}
Code: Select all
someSelector {
link: oxy_url(resolvehref(attr(href))) !important;
}
Code: Select all
Context : someSelector : link Unknown function: "resolvehref" : oxy_url (resolvehref ())
-
- Posts: 72
- Joined: Thu Mar 26, 2015 4:57 pm
Re: Custom functions in CSS oxy_url()
Post by steve.cuzner »
Re: Custom functions in CSS oxy_url()
Right now you cannot add extra functions to the set of CSS functions that Oxygen knows about. We have an issue for this and we might approach it in a future version.
We do have an oxy_xpath function:
https://www.oxygenxml.com/doc/versions/ ... ction.html
which executes an XPath 2.0 expression and XPath is quite powerful also in manipulating strings.
We also have support to add a Java StylesFilter API which would allow you to take control over how CSS styles are computed like for example:
https://www.oxygenxml.com/doc/versions/ ... ilter.html
Maybe as a possible enhancement in the future we could have an "oxy_js" CSS function which would allow you to run Javascript code set as a parameter to the function.
Could you tell me more about what the real implementation of the "resolvehref" would need to do?
Regards,
Radu
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 72
- Joined: Thu Mar 26, 2015 4:57 pm
Re: Custom functions in CSS oxy_url()
Post by steve.cuzner »
Regarding the use the the oxy_xpath function, is that limited to the current document, or could the xpath be anchored to an secondary xml file using the document() function? Would that introduce performance issues?
Re: Custom functions in CSS oxy_url()
Thanks for presenting your use-case.
The oxy_xpath can execute any XPath 2.0 expression, including the possibility to load XML files.
As stated in the user guide in the link I previously gave you it may induce performance problems. It has a parameter called evaluate which can be set to various values in order to avoid Oxygen performing lots of computations every time something changes. For example if the XPath is executed over an external XML and its results would not change depending on the CSS selector element on which the oxy_xpath is placed, you could use:
Code: Select all
oxy_xpath(
"document(a.xml)//@val",
evaluate,
static)
Radu
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 72
- Joined: Thu Mar 26, 2015 4:57 pm
Re: Custom functions in CSS oxy_url()
Post by steve.cuzner »
Re: Custom functions in CSS oxy_url()
As far as I know the oxy_xpath does not expand editor variables but the oxy_url does so you can do stuff like this:
Code: Select all
content: oxy_xpath(oxy_concat('document(', oxy_url('${pdu}', 'a.xml'), ')//@val'),
Regards,
Radu
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 72
- Joined: Thu Mar 26, 2015 4:57 pm
Re: Custom functions in CSS oxy_url()
Post by steve.cuzner »
Code: Select all
link[xlink|href]:empty{
content:oxy_xpath(oxy_concat('document(', oxy_url('${pdu}', 'a.xml'), ')//@val')) !important;
}
Code: Select all
<a val="my content"/>
Re: Custom functions in CSS oxy_url()
I made it work with something like this:
{code}content:oxy_xpath(oxy_concat('doc("', oxy_url('${pdu}/', 'a.xml'), '")//@val')) !important;{code}
The document() function is an XSLT addition to XPath so it cannot be used when running standalone XPath expressions, but you can use doc instead. Also both the doc and document functions require their string literal parameters to be quoted something like doc("file:c:/a/b/c.xml") so I added extra quotes to the literal expressions.
Regards,
Radu
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 72
- Joined: Thu Mar 26, 2015 4:57 pm
-
- Posts: 72
- Joined: Thu Mar 26, 2015 4:57 pm
Re: Custom functions in CSS oxy_url()
Post by steve.cuzner »
-
- Posts: 72
- Joined: Thu Mar 26, 2015 4:57 pm
-
- Posts: 1015
- Joined: Wed Nov 16, 2005 11:11 am
Re: Custom functions in CSS oxy_url()
Post by alex_jitianu »
Actually, starting with version 17.1, oxy_xpath() also expands xincludes. What Oxygen version are you using?
Best regards,
Alex
-
- Posts: 72
- Joined: Thu Mar 26, 2015 4:57 pm
Re: Custom functions in CSS oxy_url()
Post by steve.cuzner »
-
- Posts: 1015
- Joined: Wed Nov 16, 2005 11:11 am
Re: Custom functions in CSS oxy_url()
Post by alex_jitianu »
Perhaps you have disabled the XInclude processing? Please go to Options->Preferences on page XML / XML Parser and make sure that "Enable XInclude processing" is selected. If this isn't the cause then perhaps you can send me a small sample on support@oxygenxml.com.
Best regards,
Alex
-
- Posts: 72
- Joined: Thu Mar 26, 2015 4:57 pm
Re: Custom functions in CSS oxy_url()
Post by steve.cuzner »
-
- Posts: 1015
- Joined: Wed Nov 16, 2005 11:11 am
Re: Custom functions in CSS oxy_url()
Post by alex_jitianu »
I've sent you some sample files on your email address. These sample files work for me so perhaps we can compare them with your own and draw a conclusion...
Best regards,
Alex
-
- Posts: 409
- Joined: Mon May 09, 2016 9:37 am
Re: Custom functions in CSS oxy_url()
Post by sorin_carbunaru »
Just wanted to let you know that oXygen 19.0 has been released two days ago and in this version the oxy_xpath() CSS function supports editor variables.
Best wishes,
Sorin Carbunaru
oXygen XML
Return to “SDK-API, Frameworks - Document Types”
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service