Configure transformation scenarios boolean

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
whyme
Posts: 74
Joined: Fri Mar 08, 2013 8:58 am

Configure transformation scenarios boolean

Post by whyme » Tue Nov 17, 2020 1:34 pm

I think I've followed the instructions for Configure Transformation Scenarios > Edit scenario > Parameters > Configure Parameters > Edit correctly. I am trying to pass a value to a parameter that takes a boolean. But no matter what I type, true(), true, 1, ${xpath_eval(true())}, exists(/*) I get an error. Yes, I've checked the Evaluate as XPath box.

It seems that whatever I enter into the Oxygen options is still being interpreted as a string, because the Configure parameters list shows apostrophe marks surrounding the value of the parameter I just picked.

Or is there some secret I just don't see? This is version 22.1 build 2020061102.

tavy
Posts: 284
Joined: Thu Jul 01, 2004 12:29 pm

Re: Configure transformation scenarios boolean

Post by tavy » Wed Nov 18, 2020 9:49 am

Hello,

Thanks for your feedback.
In order to be interpreted as a boolean you can set the value of the parameter as true(), and check the Evaluate as XPath box. Even if the value is presented with quotes in the parameters dialog, it will be interpreted as a boolean value.
For example, If I run the following XSLT with the value of the "isPram" set to true(), the text "Param is set" will be displayed in the output.

Code: Select all

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0">
    <xsl:param name="isParam"/>
    <xsl:template name="xsl:initial-template">
        <xsl:if test="$isParam">Param is set</xsl:if>
    </xsl:template>
</xsl:stylesheet>
Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com

whyme
Posts: 74
Joined: Fri Mar 08, 2013 8:58 am

Re: Configure transformation scenarios boolean

Post by whyme » Wed Nov 25, 2020 9:48 am

After some diagnostics it seems that the error occurs specifically with static params. Your example code works, but not if you add static="yes" to <xsl:param>. If you haven't reconfigured the transformation scenario, the warning/error will read Parameter $isParam cannot be supplied dynamically because it is declared as static but if you unset the parameter and rebind it, running the scenario will produce this error message: The required item type of the value of variable $isParam is xs:boolean; the supplied value "true()" does not match. The supplied value is of type xs:string.

tavy
Posts: 284
Joined: Thu Jul 01, 2004 12:29 pm

Re: Configure transformation scenarios boolean

Post by tavy » Wed Nov 25, 2020 5:28 pm

Hello,

Thanks for the feedback.
Yes, it seems to be a problem when you set a static parameter from the transformation scenario. We already have an issue on our internal issue tracker for this problem. I will add your comment on the issue and increase its priority. When it will be fixed we will update this thread,
I reproduce the problem only if the type of the parameter is set to "xs:boolean". Something like this:

Code: Select all

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xsl:param name="isParam" static="yes" as="xs:boolean"/>
    <xsl:template name="xsl:initial-template">
        <xsl:if test="$isParam">Param is set</xsl:if>
    </xsl:template>
</xsl:stylesheet>
Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply