Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在xsl:when test=语句中调用特定的CSS类名,以便测试证明为真?_Css_Xslt - Fatal编程技术网

如何在xsl:when test=语句中调用特定的CSS类名,以便测试证明为真?

如何在xsl:when test=语句中调用特定的CSS类名,以便测试证明为真?,css,xslt,Css,Xslt,我有一个旋转器组件,它在主页上以一种方式运行,在其他页面上以另一种方式运行。当它位于CSS div类“tabimage”的主页上时,我想去掉另外一个属性 这是完整的代码。第一个测试是我正在做的,时间和其他方面都很好。发布这个问题后,我得出结论,我不仅需要选择CSS,还需要以某种方式区分它是否是旋转器组件的父组件,对吗 <xsl:template match="RotatorComponent[@Name='ProfileRotator']/Navigation/Page" mode="

我有一个旋转器组件,它在主页上以一种方式运行,在其他页面上以另一种方式运行。当它位于CSS div类“tabimage”的主页上时,我想去掉另外一个属性


这是完整的代码。第一个测试是我正在做的,时间和其他方面都很好。发布这个问题后,我得出结论,我不仅需要选择CSS,还需要以某种方式区分它是否是旋转器组件的父组件,对吗

<xsl:template match="RotatorComponent[@Name='ProfileRotator']/Navigation/Page" mode="Rotator">
        <xsl:param name="visible" />

        <xsl:if test="parent::node/@RotatorComponent = 'tabimage'">     
                <div class="assessimg"><a href="{@URL}" style="margin-left:500px"><img src="images/{@Thumbnail}" alt="{@ProfileName}" width="189" height="213"/></a></div>      
        </xsl:if>                   

        <xsl:choose>        
            <xsl:when test="not(/HomePage)">
                <xsl:if test="@Thumbnail">
                    <a href="{@URL}">
                        <img src="images/{@Thumbnail}" alt="{@Title}"/>
                    </a>
                </xsl:if>
                <p class="quote"><xsl:value-of select="@Quote"/></p>    
            </xsl:when>

            <xsl:otherwise>
                    <div class="module">
                        <div class="assessbox">
                            <div class="studentprofileboxinner">
                                <xsl:variable name="profileVar" select="/*/Page[@Name = 'Profile']"/>   
                                <div class="assessimg"><a href="{@URL}" style="margin-left:-5px"><img src="images/{@Thumbnail}" alt="{@ProfileName}" width="189" height="113"/></a></div            
                                <div class="assesscopy">
                                    <h3><xsl:value-of select="@ProfileType"/> Story</h3>
                                    <p><xsl:value-of select="@Abstract"/></p>
                                    <a href="{@URL}" class="assessimage"></a> <!--assessimage-->
                                    <!--assessimage-->
                                </div>          
                            </div>
                        </div>
                    </div><!-- module -->   
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>


首先,它取决于当前节点是什么,因此取决于在choose元素之前调用了什么语句。
如果当前节点是div节点,那么测试应该工作;如果不是,那么它就不会工作。

那么您是说我的test语法=“(@class='tabimage')”正确吗?第二,您询问测试的顺序是什么?您的语法是正确的,但test=“@class='tabimage'”也有效。您不需要括号。但请包括您的来源,以便我们可以验证。确保大小写正确,并且您不需要test=“@Class='tabimage'”好的,我包括了我的default.xsl,这是html所在的位置-查看第998行和我的include-rotator.xsl-查看第81行@user1272772无法理解这一行;我同意Dimitre的观点,即需要源XML/html才能对此做出合理的解释。另外,为了理解这一点,并且有人能够提供帮助,您需要提供准确的源XML文件和完整的XSLT代码。您还可以解释转换需要做什么。我更改了上面的帖子,这有帮助吗?此语法是否适用于此逻辑:测试旋转器组件的父级名称是否为tabimage。user1272772:否。没有显示XML文档时没有任何内容是正确的。
<xsl:template match="RotatorComponent[@Name='ProfileRotator']/Navigation/Page" mode="Rotator">
        <xsl:param name="visible" />

        <xsl:if test="parent::node/@RotatorComponent = 'tabimage'">     
                <div class="assessimg"><a href="{@URL}" style="margin-left:500px"><img src="images/{@Thumbnail}" alt="{@ProfileName}" width="189" height="213"/></a></div>      
        </xsl:if>                   

        <xsl:choose>        
            <xsl:when test="not(/HomePage)">
                <xsl:if test="@Thumbnail">
                    <a href="{@URL}">
                        <img src="images/{@Thumbnail}" alt="{@Title}"/>
                    </a>
                </xsl:if>
                <p class="quote"><xsl:value-of select="@Quote"/></p>    
            </xsl:when>

            <xsl:otherwise>
                    <div class="module">
                        <div class="assessbox">
                            <div class="studentprofileboxinner">
                                <xsl:variable name="profileVar" select="/*/Page[@Name = 'Profile']"/>   
                                <div class="assessimg"><a href="{@URL}" style="margin-left:-5px"><img src="images/{@Thumbnail}" alt="{@ProfileName}" width="189" height="113"/></a></div            
                                <div class="assesscopy">
                                    <h3><xsl:value-of select="@ProfileType"/> Story</h3>
                                    <p><xsl:value-of select="@Abstract"/></p>
                                    <a href="{@URL}" class="assessimage"></a> <!--assessimage-->
                                    <!--assessimage-->
                                </div>          
                            </div>
                        </div>
                    </div><!-- module -->   
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>