Assign fn:tokenize to a variable doesn'...

Help
2012-06-26
2012-10-08
  • Gerard Wolbers
    Gerard Wolbers
    2012-06-26

    Maybe I'm doing something wrong.

    When I assign an expression with fn:tokenize to a variable with xsl:variable,
    it returns an error. The type is 'Undefined', the variable is 'unavailable'.
    When I use xsl:param it works fine. This happens with Saxon6.5.5 and SaxonPE
    9.3.0.5.

     
  • Michael Kay
    Michael Kay
    2012-06-26

    Tell us (in a bit more detail...) what you are doing, and we'll tell you what
    you are doing wrong.

    The type is 'Undefined', the variable is 'unavailable'

    That doesn't look like anything Saxon is likely to put in its error messages.
    Are you sure you are running Saxon?

     
  • Gerard Wolbers
    Gerard Wolbers
    2012-06-28

    I use Oxygen to debug my xslt's. I don't get an error at all, so by checking
    the values, I see the following differnces between a variable and a param.

     
  • Gerard Wolbers
    Gerard Wolbers
    2012-06-28

    I use Oxygen to debug my xslt's. I don't get an error at all, so by checking
    the values, I see the following differnces between a variable and a param.


     
  • Michael Kay
    Michael Kay
    2012-06-28

    Sorry, rga2000, but if you want other people to help you to debug your code
    then you will have to show (a) your code, (b) the output you are getting (e.g
    error messages), and (c) the output you expect.

     
  • Gerard Wolbers
    Gerard Wolbers
    2012-06-28

    I've tried to upload two screendumps.

    The input of $list is a sequence ('Christelle Chamuleau, Jan Noordhoff',
    'Christelle Chamuleau, ROC Mondriaan').
    The input of $name is string 'author'.
    The input of $seperator is string ', '.

    My code is, using variable 'value':

    <xsl:template name="createField">
    <xsl:param name="list"/>
    <xsl:param name="name"/>
    <xsl:param name="seperator"/>
    <xsl:variable name="value" select="fn:tokenize($list, $seperator)"/>

    <rx:meta-field name="{$name}" value="{$value}"/>
    </xsl:template>

    The commented line is what eventually should give me the string 'Christelle
    Chamuleau, Jan Noordhoff, ROC Mondriaan'. For debugging I've made the
    expression a little bit more simple. Oxygen's debugger tells me:

    $value, type of value 'Undefined', value 'The variable value is unavailable.'
    $seperator, type of value 'xs:string', value ', '
    $name, type of value 'xs:string', value 'author'
    $list, type of value 'attribute(2)', value '@value='Christelle Chamuleau, Jan
    Noordhoff', @value='Christelle Chamuleau, ROC Mondriaan''

    My code is, using param 'value':

    <xsl:template name="createField">
    <xsl:param name="list"/>
    <xsl:param name="name"/>
    <xsl:param name="seperator"/>
    <xsl:param name="value" select="fn:tokenize($list, $seperator)"/>

    <rx:meta-field name="{$name}" value="{$value}"/>
    </xsl:template>

    Oxygen's debugger tells me:

    $value, type of value 'xs:string(2)', value '"Christelle Chamuleau", "Jan Noordhoff"'
    $seperator, type of value 'xs:string', value ', '
    $name, type of value 'xs:string', value 'author'
    $list, type of value 'attribute(2)', value '@value='Christelle Chamuleau, Jan
    Noordhoff', @value='Christelle Chamuleau, ROC Mondriaan''

    So, my question is why param 'value' gives me de right result and variable
    'value' doesn't.

    Thanks for all the help.

     
  • Michael Kay
    Michael Kay
    2012-06-28

    There is only one reference to the variable $value, so the Saxon optimizer
    will replace the variable reference with the initializer, that is, it will
    rewrite the expression as

    <rx:meta-field name="{$name}" value="{fn:tokenize($list[1], $seperator)}"/>
    

    So the variable doesn't actually exist any more at run-time which is why
    oXygen can't tell you its value.

    But the result of the transformation should still be correct.

     
  • Gerard Wolbers
    Gerard Wolbers
    2012-06-28

    I've tried it out and you are completely wright.

    Thanks for the help.