Problem with ${xpath_eval()} in framework

Post here questions and problems related to oXygen frameworks/document types.
Johann
Posts: 59

Problem with ${xpath_eval()} in framework

Wed Dec 16, 2015 5:08 pm

Hello everyone,

I am using the Oxygen SDK (17.1.0). I have a framework containing an action which has to create an XML fragment. This XML fragment has an attribute whose value has to be evaluated by an XPath.
I tried to use ${xpath_eval(expression)} but it seems not to work.

This is what I put in my framework file :

Code: Select all

<action>
    <field name="id">
        <String>test</String>
    </field>
    <field name="name">
        <String>test</String>
    </field>
    <field name="description">
        <String>test</String>
    </field>
    <field name="largeIconPath">
        <String></String>
    </field>
    <field name="smallIconPath">
        <String></String>
    </field>
    <field name="accessKey">
        <String/>
    </field>
    <field name="accelerator">
        <null/>
    </field>
    <field name="actionModes">
        <actionMode-array>
            <actionMode>
                <field name="xpathCondition">
                    <String/>
                </field>
                <field name="argValues">
                    <serializableOrderedMap>
                        <entry>
                            <String>fragment</String>
                            <String>&lt;foo xpath="${xpath_eval((//*/local-name())[1])}">my content&lt;/foo></String>
                        </entry>
                    </serializableOrderedMap>
                </field>
                <field name="operationID">
                    <String>ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation</String>
                </field>
            </actionMode>
        </actionMode-array>
    </field>
</action>


This action is called by an oxy_button in my document and it produces this XML fragment :

Code: Select all

<foo xpath="">my content</foo>


I also tried to use these variables : ${cfn} ${homeDir} ${framework}, they are working perfectly.

Did I write my expression in a wrong way ?

Thanks for your help.

Johann
Radu
Posts: 5088

Re: Problem with ${xpath_eval()} in framework

Thu Dec 17, 2015 2:45 pm

Hi Johann,

I took a look at this, indeed it seems that the xpath_eval editor variable never worked in the Author Component.
I will try to find a fix for this. I'm not sure if the fix will be backwards ported and incorporated in the Oxygen 17.1 SDK though.
As a workaround you can start from the code InsertFragmentOperation and implement your own custom AuthorOperation, possibly add more parameters to it and use our API to run XPaths on nodes and to modify content.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
fhorn
Posts: 16

Re: Problem with ${xpath_eval()} in framework

Wed Feb 10, 2016 4:19 pm

Hello,

we use the editor variable ${xpath_eval(expression)} in a framework action, too. Everything works fine in oXygen version 16.1
and 17.0, but not in 17.1.

It is an InsertFragmentOperation, the value of the fragment is the following:

Code: Select all

${ask('Select value', combobox, ${xpath_eval(doc("filepath/file.xml")//values/text())})}


The combobox has no fixed values. The values are generated regularly from an another xml resource and
are stored in a separate file file.xml. That is an example for the content of this file:

Code: Select all

<result>
    <values>( 'value1':'value1'; 'value2':'value2'; ), 'value1'</values>
</result>


In 16.1 and 17.0 the action works correctly, but in 17.1 the combobox has no values.
In the last post it is written that "it seems that the xpath_eval editor variable never
worked in the Author Component." That refers to version 17.1 and it means that is currently
not possible to use the editor variable in an action in a framework, right?

Regards
Franziska
Radu
Posts: 5088

Re: Problem with ${xpath_eval()} in framework

Wed Feb 10, 2016 4:51 pm

Hi Franziska,

The Author Component is a special sub-product which can be integrated in other Java applications.
You have this problem in a standalone Oxygen (XML Editor or XML Author) installation, right?
I tried to create an Author action in an Oxygen XML Editor 17.1 installation using the details you provided. It worked for me, the combo box in the dialog had values.
In the XPath doc file I used as a path to the XML configuration file a path relative to the current opened XML document. In your case does that path to the XML configuration file point to a remote location or is it also a path relative to the current edited XML document?

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Radu
Posts: 5088

Re: Problem with ${xpath_eval()} in framework

Wed Feb 10, 2016 4:52 pm

One more thing to help you debug:

In the Oxygen installation folder there are startup scripts, something like oxygen.bat. If you start Oxygen using that script and then invoke the action, you may get in the command prompt which was started more details about why the XPath failed.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
fhorn
Posts: 16

Re: Problem with ${xpath_eval()} in framework

Wed Feb 10, 2016 7:46 pm

Hi Radu,

thank you for clarifying this and testing the Author action! You're right, I'm using the standalone Oxygen (XML Editor).

The path points to a file stored on a WebDAV resource (eXist server 2.1). It is not a path relative to the current opened XML document.
If the file is stored locally on my computer it works, the combo box has values. Probably there is a problem to access the server:

Code: Select all

[...] ro.sync.util.editorvars.EditorVariables - ro.sync.xml.xpath.g: XPath failed due to: I/O error reported by XML parser processing http://web.domain.net/.../values.xml: access denied ("java.net.URLPermission" "http://web.domain.net/.../values.xml" "GET:")

ro.sync.xml.xpath.g: XPath failed due to: I/O error reported by XML parser processing http://web.domain.net/.../values.xml: access denied ("java.net.URLPermission" "http://web.domain.net/.../values.xml" "GET:") [...]

There is no difference if I add a username and/or password (e.g. http://username@web.domain.net/.../values.xml)
In version 17.0 there is no problem to access the server, sometimes a window appears to register with eXist username and password.

Regards
Franziska
Radu
Posts: 5088

Re: Problem with ${xpath_eval()} in framework

Thu Feb 11, 2016 11:18 am

Hi Franziska,

Thanks for posting the console output and for the details about the XML over which the XPath is run being on a remote server.
In Oxygen 17.1 we added some security constraints to somehow restrict the editor from sending or retrieving content from remote locations.
In the Oxygen Preferences->Network Connection Settings / Trusted hosts we have a list of trusted hosts but unfortunately this does not work in your case.
I will add an internal issue for this and try to find and incorporate a fix in the next Oxygen 17.1 minor bug fix release (in a couple of weeks).
This forum thread will be updated when the new kit is available on our web site.
Until then one possibility is to set a system property to the application which disables all security checks.
In you are running on Windows, in the Oxygen installation folder there is an oxygen17.1.vmoptions configuration file which you can edit and add an extra line to it at the end:

Code: Select all

-Dcom.oxygenxml.disable.security=true


If you are running on Mac OSX this topic describes what it takes to set an Oxygen system property there:

https://www.oxygenxml.com/doc/versions/17.1/ug-editor/#topics/set-parameters-for-application-launchers.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
emylonas
Posts: 10

Re: Problem with ${xpath_eval()} in framework

Fri Feb 12, 2016 2:08 am

Just another note - I have created an oxygen author framework, and use the following in my CSS:

Code: Select all

oxy_xpath('string-join(//encodingDesc/xi:include/doc(@href)/classDecl/taxonomy[@xml:id="IIP-genre"]/category/@xml:id , ",")

the file that is being accessed via the doc(@href) is a remote file
For me as well, everything worked fine since about Oxygen 15, but 17.1 broke the expression.

I presume this is the same issue as is being discussed above. Do you think the next minor fix may address this or is there something else to do?

This is where the add-on lives:
http://cds.library.brown.edu/projects/Inscriptions/oxygen/iip-addon.xml

thank you
emylonas
Posts: 10

Re: Problem with ${xpath_eval()} in framework

Fri Feb 12, 2016 2:12 am

by the way, I just tried setting a trusted host in the preferences of
*brown.edu
but it had no effect.
thanks again.
Radu
Posts: 5088

Re: Problem with ${xpath_eval()} in framework

Fri Feb 12, 2016 10:39 am

Hi Elli,

This looks like an identical situation, if you start Oxygen using the command line executable script (that I suggested earlier on this thread) you should see in the console security exceptions when the action is run.
I will add your feedback to the issue and it will be fixed in the next Oxygen 17.1 minor bug fix release in at most a month.
Indeed adding the URL in the list of trusted hots does not work.
The only workaround I gave on this thread was to set that system property to Oxygen in order to disable all security checks.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
fhorn
Posts: 16

Re: Problem with ${xpath_eval()} in framework

Fri Feb 26, 2016 1:27 pm

It works fine if I set that system property to Oxygen as you described it, thank you!

In spite of that workaround is it by any chance still possible to download version 17.0 via the oxygen homepage? I'm asking because the version is not listed in the software archive. Probably only the latest release versions are offered (e.g. 17.1, 16.1. and not 17.0 and 16.0).

Regards
Franziska
adrian
Posts: 2326

Re: Problem with ${xpath_eval()} in framework

Fri Feb 26, 2016 3:29 pm

Hi,

As you've observed, only the latest minor version/update is available for download for each major version.
If you need a specific version that is not directly available for download, please write to our support email address (support@oxygenxml.com) and mention the exact version, product (Editor, Author, Developer), platform (Windows/Mac/Linux) and architecture (32/64).

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
fhorn
Posts: 16

Re: Problem with ${xpath_eval()} in framework

Mon Feb 29, 2016 12:43 pm

Hi Adrian,

thank you, it's good to know that this is possible!

Regards,
Franziska
alex_jitianu
Posts: 600

Re: Problem with ${xpath_eval()} in framework

Thu Mar 24, 2016 12:21 pm

Hi,

We've just released of a new maintenance build (2016032212) for oXygen 17.1 in which we've addressed the issues reported in this thread:

1. ${xpath_eval()} inside an Author Action will succeed even when it reads data from a remote file.
2. if the CSS oxy_xpath() function reads data from a remote file then:
- if the CSS is local and located inside the framework directory, the oxy_xpath() will succeed without any required interaction
- if the CSS is remote (Elli's situation) a confirmation dialog will appear to the user. Adding the host inside the Trusted Hosts preferences page will result in connecting to the remote location without notifying the user.

Best regards,
Alex
Radu
Posts: 5088

Re: Problem with ${xpath_eval()} in framework

Thu May 05, 2016 9:22 am

Hi,

About the first issue this thread was started on, which stated that in the Author Component the xpath_eval does not work, this should be fixed in the 18.0 SDK.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
emylonas
Posts: 10

Re: Problem with ${xpath_eval()} in framework

Wed Mar 08, 2017 11:37 pm

It's been a while since I initially had this problem and I stay in Oxygen 16 (Mac) because my Author forms didn't work otherwise (see above posting). I have finally found a solution for working with xi:includes in Author mode that work in the current version of Oxygen. I adopted a slightly different approach for constructing an xpath - rather than relying on the xi:include to retrieve the file then construct the xpath, I am just retrieving the local file from a directory in the framework using the doc() function.

In addition to retrieving the file and constructing an xpath inside it, I need to manage multiple values, in order to populate a multiple choice form control. This is the expression I came up with, with correct quoting (possibly the hardest part)

Code: Select all

            values, oxy_xpath(oxy_concat('string-join(doc("', oxy_url('${framework}/', 'resources/include_taxonomies.xml'), '")//taxonomy[@xml:id="IIP-genre"]/category/@xml:id, ",")')),
             labels, oxy_xpath(oxy_concat('string-join(doc("', oxy_url('${framework}/', 'resources/include_taxonomies.xml'), '")//taxonomy[@xml:id="IIP-genre"]/category/catDesc, ",")' ))


This may be useful to other Oxygen users who need to work with xi:include files in form controls. I was never able to get the include to work as described above by Radu, - my fault, I'm sure.
fhorn
Posts: 16

Re: Problem with ${xpath_eval()} in framework

Tue Aug 01, 2017 5:48 pm

Hi,

we are using a CSS oxy_xpath() function in a combo box form control. The oxy_xpath() function reads data from a remote file.
As you described above a confirmation dialog appears to the user. Everything works fine if we select "allow and remember".

But at first I tried this: I selected "allow" and the dialog closed. Then I tried to select a value from the combo box in author mode and oXygen froze. This happened repeatedly in version 18.0 and 18.1. We just wanted to let you know.

Best regards
Franziska
sorin_carbunaru
Site Admin
Posts: 111

Re: Problem with ${xpath_eval()} in framework

Thu Aug 03, 2017 1:29 pm

Hello Franziska,

Thank you for reporting this to us. Indeed, I managed to get what seemed to be a freezing in oXygen 18.0. I also tried with 19.0, and fortunately it didn't freeze, so it seems like some improvements have been made by by colleagues. On the other hand, even though oXygen didn't freeze, I got an unexpected error message, and I will record an issue on our side for this.

Kind regards,
Sorin Carbunaru
oXygen XML

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

Who is online

Users browsing this forum: No registered users and 0 guests