How to enter numeric stylesheet paramaters?
Are you missing a feature? Request its implementation here.
-
- Posts: 2
- Joined: Wed Feb 22, 2006 3:19 pm
How to enter numeric stylesheet paramaters?
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
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
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
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
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
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Post by sorin_ristache »
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
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
-
- Posts: 2
- Joined: Wed Feb 22, 2006 3:19 pm
Sorin,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![]()
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.

Regards,
Martin
-
- Posts: 26
- Joined: Wed Jun 26, 2013 1:08 am
Re: How to enter numeric stylesheet paramaters?
Post by avanlooveren »
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.
<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.
-
- Posts: 417
- Joined: Mon May 09, 2016 9:37 am
Re: How to enter numeric stylesheet paramaters?
Post by sorin_carbunaru »
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:
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.
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>
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.
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service