custom editor variables using other variables

Post here questions and problems related to oXygen frameworks/document types.
steve.cuzner
Posts: 72
Joined: Thu Mar 26, 2015 4:57 pm

custom editor variables using other variables

Post by steve.cuzner »

In our environment we have a folder for each product, but shared resourced are stored at folders higher in the tree such as

Code: Select all


allproducts
stylesheets
src
product1
product1.xpr
product2
product2.xpr
I'd like to be able to have a variable, ${stylesheets}, that has the path to the stylesheets directory relative to the project folder. I've tried directly referencing ${pd} in my custom variable definition in the project file,

Code: Select all



<userEditorVariable>
<field name="name">
<String>${stylesheets}</String>
</field>
<field name="value">
<String>${pd}\..\..\stylesheets</String>
</field>
<field name="shortDescription">
<String>The stylesheets directory of the sandbox</String>
</field>
</userEditorVariable>
and using the xpath_eval construction method.

Code: Select all



<userEditorVariable>
<field name="name">
<String>${stylesheets}</String>
</field>
<field name="value">
<String>${xpath_eval(concat(${pd}, '\..\..\stylesheets'))}</String>
</field>
<field name="shortDescription">
<String>The stylesheets directory of the sandbox</String>
</field>
</userEditorVariable>
Neither seem to work, but perhaps I've got my number of .. steps in the path wrong. Is there a way to validate what a variable expands to in an editor viewer so you can more easily debug possible variable construction errors?
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: custom editor variables using other variables

Post by mihaela »

Hi,

I tried to reproduce your problem but the custom variable value worked for me when directly referencing ${pd}.
Indeed there is a problem in the second construction method (the one that uses xpath_eval function). The arguments of the concat function must be strings so you have to wrap ${pd} value in quotes:

Code: Select all

${xpath_eval(concat("${pd}", '\..\..\stylesheets'))}
Can you please tell me the oXygen version that you are using? I have checked your samples using the last released version (17.0).
Another question is how do you use the custom editor variable?

I think that you can check the expressions by using them in a CSS (maybe as content for an element).

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
steve.cuzner
Posts: 72
Joined: Thu Mar 26, 2015 4:57 pm

Re: custom editor variables using other variables

Post by steve.cuzner »

I'm using <oXygen/> XML Editor 17.0, build 2015052917

I'll try the css. Having an evaluation window/widget would be a great new feature.
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: custom editor variables using other variables

Post by mihaela »

Hi,

I have added your feature request in our internal issue tracker (to add a way to evaluate editor variables).
We will let you know when this will be available.

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
steve.cuzner
Posts: 72
Joined: Thu Mar 26, 2015 4:57 pm

Re: custom editor variables using other variables

Post by steve.cuzner »

I've been trying to output a variable in my css and am not having any luck. Here is my code:

Code: Select all


info:before {
content: "Using ${pd}";
}
All I get is the literal ${pd}. If I move the variable outside the quotes, i get an error due to the }. I've searched help, forums, and looked in the distributed css for the docbook framework, but can't fine any information on how to use a variable for css.

Steve
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: custom editor variables using other variables

Post by mihaela »

Hi Steve,

The ${pd} variable is not directly expanded if you are using it in the node content.
What you can do is to use its ${pdu} equivalent (that returns the current project folder as URL) inside an oxy_url function:

info:before {
content: oxy_url('${pdu}');
}

Regarding to your initial problem (the custom variable that points to the stylesheets directory) can you send us a small sample that reproduces your problem? In this way maybe we could help you find a solution. Here is our support email address: support@oxygenxml.com.


Best regards,
Mihaela.
Mihaela Calotescu
http://www.oxygenxml.com
Post Reply