${ask} editor variable return an error

Having trouble installing Oxygen? Got a bug to report? Post it all here.
ArthurP
Posts: 11
Joined: Mon Dec 11, 2023 3:10 pm

${ask} editor variable return an error

Post by ArthurP »

Hi,
I'm using a custom action in CSS, that use the editor variable ${ask}. We use this editor variable to ask for an URL that will be used as an xslt parameter.

Code: Select all

{
  content: 
  oxy_button(action, oxy_action(
name, '[+Button]', 
description, 'description', 
operation, 'ro.sync.ecss.extensions.commons.operations.XSLTOperation', 
arg-script, 'actions/custom.xslt', 
arg-action, 'Replace', 
arg-externalParams, "g-url=${ask('Enter an URL : ', url)}"
), 
transparent, true, 
actionContext, element, 
showIcon, true);
  color: blue;
  font-weight: bold;
}
This URL "https://www.youtube.com/?gl=FR&hl=fr" return an error

Code: Select all

Chunk [g-url="https://www.youtube.com/?gl=FR&hl=fr"] is not a valid entry.
I'm using oXygen Desktop 25.1 and a custom DITA framework.
Thanks for your help!
xephon
Posts: 139
Joined: Mon Nov 24, 2014 1:49 pm
Location: Greven/Germany

Re: ${ask} editor variable return an error

Post by xephon »

I guess you need to use the & entity instead of & in the URL.
stefan-jung.org – Your DITA/DITA-OT XML consultant
Radu
Posts: 9041
Joined: Fri Jul 09, 2004 5:18 pm

Re: ${ask} editor variable return an error

Post by Radu »

Hi,

This "Chunk ... is not a valid entry." does not seem to be an error Oxygen would throw from what I looked in our code.
So your CSS button invokes an XSLT operation with a parameter named "externalParams":
https://www.oxygenxml.com/doc/versions/ ... l1_dgk_54b
In the value of "externalParams" you are expanding an ask editor variable which will show a dialog to the end user and the end user will probably paste an URL there.
Did you define an xsl:param with name "g-url" in your stylesheet in order to get there the value of the URL? Do you receive the proper value in the stylesheet? What do you do further with that value?
Can you show me a screenshot with the entire Oxygen screen at the time the error is reported to you?

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
ArthurP
Posts: 11
Joined: Mon Dec 11, 2023 3:10 pm

Re: ${ask} editor variable return an error

Post by ArthurP »

Hi,

@Stefan : I already tried URL escaping. '&' is correctly converted to &amp;, it's '=' that cause trouble.
@Radu
In the value of "externalParams" you are expanding an ask editor variable which will show a dialog to the end user and the end user will probably paste an URL there.
Yes, exactly
Did you define an xsl:param with name "g-url" in your stylesheet in order to get there the value of the URL? Do you receive the proper value in the stylesheet? What do you do further with that value?
Our XSLT looks like this.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
    xmlns:saxon="http://saxon.sf.net/" exclude-result-prefixes="saxon xs xd" version="2.0">

    <!-- This is an XPath location to be sent by the operation to the script -->
    <xsl:param name="currentElementLocation"/>
    <!-- url fournie en paramètre -->
    <xsl:param name="g-url" as="xs:anyURI?"/>

    <xsl:variable name="position" select="saxon:eval(saxon:expression($currentElementLocation))"
        as="element()"/>

    <xd:doc>
        <xd:desc>
            <xd:p></xd:p>
        </xd:desc>
    </xd:doc>
    <xsl:template match="/*">
        <xsl:copy>
            <xsl:attribute name="href" select="$g-url"/>
            <xsl:attribute name="format" select="'html'"/>
            <xsl:attribute name="scope" select="'external'"/>
            <xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>

</xsl:stylesheet>
What I tried :
  • changing XSLT version 2.0 to 3.0
  • changing "g-url" parameter type to "xs:string", to nothing
  • in CSS action, changing "url" to "generic"
  • having paramter "g-url" but not using it
Even removing type on "g-url" and setting "generic" parameter in ${ask}, throw an error with just character "="
before.png
before.png (644.97 KiB) Viewed 210 times
after.png
after.png (674.37 KiB) Viewed 210 times
EDIT : I created a new framework, disabling all my custom framework and the problem is still here. "=" should be the issue ...
Attachments
Capture d’écran 2024-02-23 à 10.28.19.png
Capture d’écran 2024-02-23 à 10.28.19.png (674.37 KiB) Viewed 210 times
Radu
Posts: 9041
Joined: Fri Jul 09, 2004 5:18 pm

Re: ${ask} editor variable return an error

Post by Radu »

Hi,
I managed to setup and reproduce the problem on my side, the "arg-externalParams" parameter takes a comma separated list of "paramName=paramValue" so once the value starts like in your case having "=" inside it, the parameters parser breaks.
I added an internal issue based on this problem, pasting the issue ID below for future reference:
EXM-54248 Cannot specify parameter value containing "=" for xslt operation
But I'm not sure about how to approach this, maybe allow wrapping the values in some sort of quotes if they contain equal signs inside them...
A hack in such a case may be to show the URL input dialog directly from the XSLT stylesheet:

Code: Select all

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
    xmlns:saxon="http://saxon.sf.net/" 
    exclude-result-prefixes="saxon xs xd" version="2.0"
    xmlns:optionpane="java:javax.swing.JOptionPane">

    <!-- This is an XPath location to be sent by the operation to the script -->
    <xsl:param name="currentElementLocation"/>
    <!-- url fournie en paramètre -->
    <xsl:param name="g-url" select="optionpane:showInputDialog(null, 'ENTER URL')"/>
and remove the parameter from the CSS side:

Code: Select all

  content: 
  oxy_button(action, oxy_action(
name, '[+Button]', 
description, 'description', 
operation, 'ro.sync.ecss.extensions.commons.operations.XSLTOperation', 
arg-script, 'actions/custom.xslt', 
arg-action, 'Replace'
), 
transparent, true, 
actionContext, element, 
showIcon, true);
  color: blue;
  font-weight: bold;
Btw, recent versions of the Saxon processor no longer support saxon:eval, you would need to use the xsl:evaluate element and raise the XSLT version to 3.0.
By the way, what are you attempting to do? When someone pastes an URL over a selection, attempt to wrap it in a DITA <xref> link to that URL?
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
ArthurP
Posts: 11
Joined: Mon Dec 11, 2023 3:10 pm

Re: ${ask} editor variable return an error

Post by ArthurP »

Hi Radu,

thanks for your explanation. It was strange because we use this action since at least 2 years with no problem. We recently upgrade oXygen to 25.1, maybe something changed.
I will try your hack, or find an other method.
Btw, recent versions of the Saxon processor no longer support saxon:eval, you would need to use the xsl:evaluate element and raise the XSLT version to 3.0.
thanks, we are migrating this framework to webauthor and newer version of oxygen so I will definitively to this.
By the way, what are you attempting to do? When someone pastes an URL over a selection, attempt to wrap it in a DITA <xref> link to that URL?
An user can input a specialized xref without attribute such as <lire/>. We use this action to add an @href attribute on this element by asking user the desire URL.
Radu
Posts: 9041
Joined: Fri Jul 09, 2004 5:18 pm

Re: ${ask} editor variable return an error

Post by Radu »

Hi Arthur,
As far as I know from when we originally wrote the XSLTOperation it splits the parameters by "=". But it's possible that as the problem occurs in certain cases when the URL contains "=", maybe nobody else on your team pasted before such an URL in the ask dialog until now.
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply