There is xml (30K lines) which at the 1st processing stage should be turned into a template.

<Test> <data_type>numeric</data_type> <value>83.79</value> </Test> <OBJECTIVE> <data_type>string</data_type> <value>string</value> </OBJECTIVE> <EDITIONDATE> <data_type>string</data_type> <value>string</value> <date_format>yyyyDDD</date_format> </EDITIONDATE> 

If you rely on value and depending on it value = 83.79 - 1 logic value = string check if date_format is on the same level if there is a date. I concocted

 <xsl:template match="//value"> <xsl:variable name="val" select="string(value)"/> <xsl:choose> <xsl:when test="$val = string"> <xsl:text>string</xsl:text> </xsl:when> <xsl:when test="$val=83.79"> <xsl:text>numeric</xsl:text> </xsl:when> </xsl:choose> </xsl:template> 

He works out only the 2nd, because he always thinks that 83.79 he was looking for a cast was not found. What should the template look like solving my problem?

    1 answer 1

    This expression:

     select="string(value)" 

    assigns an empty string to a variable, since there is no value node in the current context (you already found it in the match expression).
    Obviously, should be:

     select="string(.)" 

    Further, in the expression

     test="$val = string" 

    there is a comparison with a node named string . Naturally, there is no such node.
    It should be:

     test="$val = 'string'" 

    The value of the literal quote.
    The number, in theory, also needs to be added, although the parser understands without quotes that this is not the name of the node.