oxy:current-element()

Having trouble installing Oxygen? Got a bug to report? Post it all here.
whyme
Posts: 89
Joined: Fri Mar 08, 2013 8:58 am

oxy:current-element()

Post by whyme »

The very helpful instructions at Built-in Author Mode Operations > XSLTOperation and XQueryOperation advises the use of oxy:current-element(), but I can't replicate the code example there without an error both in the XSLT (Cannot find a 0-argument function named Q{http://www.oxygenxml.com/ns/author/xpat ... nt-element()) and in the XML being edited in Author mode (Couldn't execute operation: 'ro.sync.ecss.extensions.commons.operations.XSLTOperation'
for action: 'Get LM data' because of:

class java.lang.RuntimeException - Internal error evaluating template rule at line 12 in module)

I'm sure there must be a setting or parameter that's missing, but the documentation doesn't tell me where to look. The zero-arity function doesn't show up anywhere else in the Web documentation.
alex_jitianu
Posts: 1009
Joined: Wed Nov 16, 2005 11:11 am

Re: oxy:current-element()

Post by alex_jitianu »

Hello,

The oxy:current-element() was introduced in Oxygen version 21. What Oxygen version are you running?

Best regards,
Alex
whyme
Posts: 89
Joined: Fri Mar 08, 2013 8:58 am

Re: oxy:current-element()

Post by whyme »

V. 23
whyme
Posts: 89
Joined: Fri Mar 08, 2013 8:58 am

Re: oxy:current-element()

Post by whyme »

Build 2020111805
alex_jitianu
Posts: 1009
Joined: Wed Nov 16, 2005 11:11 am

Re: oxy:current-element()

Post by alex_jitianu »

Hello,

With want type of documents are you working? Have you customized a built-in framework, like the DITA framework, by editing the framework resources?

Each framework has a jar file with specific operations as well as the common operations, like the XSLTOPeration. If you've customized a built-in framework from an older version of Oxygen and didn't update this jar file (as well as other resources) when you migrated to a newer Oxygen version, then you don't have the newer, updated author operations. To see if this is the case, copy dita.jar (if your framework is DITA) from a pristine Oxygen into your framework and replace the existing one.

Actually, it is recommended to extend a framework (either from the GUI or with an extension script)so that when you pass to a newer Oxygen version the merging is done automatically.

Best regards,
Alex
whyme
Posts: 89
Joined: Fri Mar 08, 2013 8:58 am

Re: oxy:current-element()

Post by whyme »

I'm working through an externally saved framework, so no jar files are involved AFAIK. Let me try a couple of things on my end.
whyme
Posts: 89
Joined: Fri Mar 08, 2013 8:58 am

Re: oxy:current-element()

Post by whyme »

I have been able to replicate the oxy:current-element() example by creating a fresh project, a fresh external frameworks file, and a fresh author action. A second new author action based upon the XSLT that was giving my other external frameworks file problems also works fine.

Now, staying within the same fresh project, I tried to replicate the successful author action but as a part of the other external frameworks file. I got the familiar compile error.

So clearly this problem is related not to the project or to the XSLT file but to the external frameworks file. I've visually inspected the two frameworks files, which are just XML, and I can't see any mechanism that would dictate different results. Is it something in my global settings? Any other ideas? How does an external frameworks file get handled?

By the way, in the successful author action XSLT file, the line <xsl:apply-templates select="oxy:current-element()"/> is marked as invalid within Oxygen, even though it successfully drives the Author action.
whyme
Posts: 89
Joined: Fri Mar 08, 2013 8:58 am

Re: oxy:current-element()

Post by whyme »

The problematic frameworks file does not include any entries under classpath or extensions, so there shouldn't be any conflicts from external Java resources.
alex_jitianu
Posts: 1009
Joined: Wed Nov 16, 2005 11:11 am

Re: oxy:current-element()

Post by alex_jitianu »

Hello,
By the way, in the successful author action XSLT file, the line <xsl:apply-templates select="oxy:current-element()"/> is marked as invalid within Oxygen, even though it successfully drives the Author action.
This extension function is installed only in the context of author actions, so its normal not to be recognized in an opened editor.
Can you send me this problematic external framework on support@oxygenxml.com to have a look at it? Perhaps the project as well.

Best regards,
Alex
whyme
Posts: 89
Joined: Fri Mar 08, 2013 8:58 am

Re: oxy:current-element()

Post by whyme »

Hi Alex, I figured it out.

An XML file with comments, process instructions, or CData appears to trip up the evalutaion of oxy:current-element().

Suppose a root element that wraps one comment followed by two elements. The cursor is in the first child element. When the action is applied, the second child element gets evaluated.

Now, inside that second child element create a new child element and put the cursor inside. When the author action is evaluated, you will get a compile/evaluation error.

If you remove the comment, the author action will perform as expected.

The errors above can be replicated by changing the comment with a processing instruction or CData.
alex_jitianu
Posts: 1009
Joined: Wed Nov 16, 2005 11:11 am

Re: oxy:current-element()

Post by alex_jitianu »

Hi,

Good catch! I've manage to reproduce the the problem and I've recorded an issue. We will let you know as soon as we release a version that contains the fix.

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

Re: oxy:current-element()

Post by alex_jitianu »

Hi,

Until we fix this situation, you can try using a different operation, like JSOperation, which has access to the current element and more by using the Java API.

Best regards,
Alex
Cosmin Duna
Site Admin
Posts: 120
Joined: Wed Dec 12, 2018 5:33 pm

Re: oxy:current-element()

Post by Cosmin Duna »

Hello,

I just wanted to let you know that Oxygen 24.0 is out now and it contains a fix for the issue you reported on this thread.

Best regards,
Cosmin
Cosmin Duna
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply