How to enter numeric stylesheet paramaters?

Are you missing a feature? Request it's implementation here.
Marty
Posts: 2

How to enter numeric stylesheet paramaters?

Wed Feb 22, 2006 3:46 pm

Hello,

When entering values for stylesheet parameters they are automatically enclosed by single quotes and passed as strings. Is there a possibility to enter numeric values that are not quoted?

Greetings,
Marty
sorin_ristache
Posts: 4144

Wed Feb 22, 2006 6:30 pm

Hello,

In <oXygen/> you will obtain the same results as in the command line when you apply the same stylesheet with the same transformer.

For example if you want to pass a numeric parameter to an XSLT 1.0 stylesheet applied with Saxon 6.5 you enter the value in the Configure Parameters dialog and when you use the parameter in a numeric expression in your stylesheet Saxon 6.5 converts it automatically to a number. In this case you should just ignore the quote marks in the Value column of the parameters table.

If it is an XSLT 2.0 stylesheet you have to convert the parameter value to a number explicitly (using the number() function) when you use it in numeric expressions because the type checking is more strict in XSLT 2.0 and string values are not converted automatically to numbers.

Regards,
Sorin
sorin_ristache
Posts: 4144

Wed Feb 22, 2006 6:48 pm

Hello again,

Considering the matter more carefully we are thinking about allowing for a way to specify the parameter type in the Configure parameters dialog (number, string literal, boolean, nodeset/sequence). So this becomes a feature request :)

Regards,
Sorin
Marty
Posts: 2

Wed Feb 22, 2006 7:29 pm

sorin wrote:Considering the matter more carefully we are thinking about allowing for a way to specify the parameter type in the Configure parameters dialog (number, string literal, boolean, nodeset/sequence). So this becomes a feature request :)


Sorin,

thanks for your quick reply.
Such a new feature in one of the next versions would be great, because in some cases the xslt-processor doesn't convert a "numeric string" automagically to the intended value, e.g. if used as a boolean expression like
<xsl:if test="$param">...</xsl:if>.
If param is '0' the test always succeeds, if param equals 0 it fails. :wink:

Regards,
Martin
avanlooveren
Posts: 25

Re: How to enter numeric stylesheet paramaters?

Wed Jun 28, 2017 10:46 pm

Is there any progress on this? I have boolean stylesheet parameters like this:

<xsl:param name="includeTranscript" select="true()"/>

but it is not clear to me how to get the value to be boolean when I use the ${ask} editor variable like this:

${ask('Include captioning?', radio, ('true()':'yes'; 'false()':'no'),'true()')}

The above seems to work if I check "Evaluate as XPath" checkbox, but then it asks me on each additional stylesheet in the transformation scenario. Without quotes (...(true():'yes'; false:'no')...) did not work.
sorin_carbunaru
Site Admin
Posts: 111

Re: How to enter numeric stylesheet paramaters?

Fri Jun 30, 2017 4:33 pm

A solution that we have thought about is to create an Ant transformation scenario that has the ${ask} editor variable as parameter. This way it will get evaluated only once, and you can pass the resulted value to multiple stylesheets. Each stylesheet will have as input the output of the previous, to simulate the behavior of the XSLT scenario with additional stylesheets.

The Ant build would look something like this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<project basedir="." name="testProj" default="mainTarget">
 
  <!-- The result of the ${ask} evaluation. The property has the same name as the parameter defined in the Ant transformation scenario. -->
  <property name="askParam" value="'true()'"/>

  <!-- Main target -->
  <target name="mainTarget">

    <!-- Output files. -->
    <property name="step1.output" value="out1.xml"/>
    <property name="step2.output" value="out2.xml"/>

    <!-- First transformation -->
    <xslt style="firstStyleSheet.xsl" in="input.xml" destdir="." out="${step1.output}" force="true">
      <param name="includeTranscript" expression="${askParam}" type="XPATH_BOOLEAN"/>
    </xslt>

    <!-- Second transformation. The input of this stylesheet is actually the output of the previous. -->
    <xslt style="secondStyleSheet.xsl" in="${step1.output}" destdir="." out="${step2.output}" force="true">
      <param name="includeTranscript" expression="${askParam}" type="XPATH_BOOLEAN"/>
    </xslt>

  </target>

</project>


When you create the Ant scenario:
1. Add [oXygen_dir]/lib/saxon9ee.jar to the list of used libraries (see the Libraries buttton in the bottom-right corner of the Output tab).
2. Add askParam with the value ${ask('Include captioning?', radio, ('true()':'yes'; 'false()':'no'),'true()')} as a transformation parameter (see Parameters tab).

You can read more about Ant transformations at: https://www.oxygenxml.com/doc/versions/ ... ation.html.

Return to “Feature Request”

Who is online

Users browsing this forum: No registered users and 1 guest