exsl:document in xsl:if block

前端 未结 1 1457
别跟我提以往
别跟我提以往 2020-12-22 12:07

Here is a toned down version of my use case.

1) I have a transformation xsl file which is as follows




        
相关标签:
1条回答
  • 2020-12-22 12:51

    The main problem here is that you're defining dotransformation as a result tree fragment and not a boolean value. Only an empty fragment is false, so your test $dotransformation = true() is always true

    You have a few options. The most obvious is to put a real boolean value into dotransformation like this

    <xsl:variable name="dotransformation" select="$isfile = 'true'" />
    

    then your existing test will work, or you may say just

    <xsl:if test="$dotransformation">
    

    Alternatively, of course, you may write simply

    <xsl:if test="$isfile = 'true'">
    

    and forget about the intermediate variable

    Another issue is that the match="Author" template is executed only because you have

    <xsl:apply-templates select="/Article/Authors/Author" />
    

    within the conditional section. If that section is disabled then there is nothing to cause anything beneath the root node to be processed and, as it stands, neither file will be generated

    The solution is to put a simple recursion template in there that will cause the processor to follow through all the layers of elements

    <xsl:template match="*">
        <xsl:apply-templates select="*" />
    </xsl:template>
    
    0 讨论(0)
提交回复
热议问题