English 中文(简体)
适用于模板的xsl conditoneck
原标题:xsl conditon check in apply template
  • 时间:2012-04-20 09:47:55
  •  标签:
  • xslt

我的x

<root>
    <tests>
        <test id="222">
         <actionId>233</actionId>
        </test>
        <test id="22">
         <actionId>23333</actionId>
        </test>
    </tests>
    <confs>
        <conf id="2211"></conf>
    </confs>
</root>

    <xsl:key name="confId" 
        match="confs/conf" 
        use="@id" /
<xsl:template match="main">
Test:
<xsl:apply-templates select="tests/test" />
</xsl:template>
 <xsl:template match="tests/test">
<xsl:choose>
            <xsl:when test="actionId[.=  ]">
                <li>
                    <xsl:choose>
                        <xsl:when test="key( confId , @id)">
                            Used </xsl:when>
                        <xsl:otherwise> Not found</xsl:otherwise>
                    </xsl:choose>
                </li>
            </xsl:when> 
            <xsl:otherwise> <li>Not at all found</li></xsl:otherwise>
        </xsl:choose>
 </xsl:template>

现在 并非所有已发现的电文都印在每张印本上,作为行动匹配的模板上。 Id并非无效,它只需要一度印刷,但不能执行。

预期产出

  • Not at all found
  • is printed only once when actionId in the tests/test template never finds a match, ie
  • Not at all found
  • is not iterated in the template
    问题回答

    每当“测试”模板启动时,它只能使用通过源文件测试要素或模板参数或全球变量获得的信息。 它无法利用以往启动活动的任何知识,因为锡索托公司是无国籍的。

    如果你想要处理第一个测试要素不同于其他要素,那么就写了两个不同的模板规则。

    如果你想用行动专门处理第一个测试要素,那么就应拟订一个模板规则,使之符合:

    <xsl:template match="test[actionId[.=  ][1]">
    




    相关问题
    When test hanging in an infinite loop

    I m tokenising a string with XSLT 1.0 and trying to prevent empty strings from being recognised as tokens. Here s the entire function, based on XSLT Cookbook: <xsl:template name="tokenize"> ...

    quick xslt for-each question

    Let s say I have an XML document that has this: <keywords> <keyword>test</keyword> <keyword>test2</keyword> <keyword>test3</keyword> <keyword>test4</...

    XSLT Transform XML with Namespaces

    I m trying to transform some XML into HTML using XSLT. Problem: I can t get it to work. Can someone tell me what I m doing wrong? XML: <ArrayOfBrokerage xmlns:i="http://www.w3.org/2001/...

    XSLT output to HTML

    In my XSLT file, I have the following: <input type="button" value= <xsl:value-of select="name">> It s an error as it violates XML rule. What I actually want is having a value from an ...

    Mangling IDs and References to IDs in XML

    I m trying to compose xml elements into each other, and the problem I am having is when there s the same IDs. Basically what I need to do is mangle all the IDs in an xml file, as well as the ...

    Sharepoint 2007 Data view Webpart custom parameters

    I m sort of new to the custom parameters that can be setup on a DataView Webpart. There are 6 options: - None - Control - Cookie - Form - QueryString - Server Variable I think that None, Cookie and ...

    热门标签