xsl:for-each中引用循環外全局變量


//全局變量

<xsl:variable name="temp_driving_type" select="WebPage/Data/OptReturnData[@OptRetName='GetEmpCarById']/OptRetData/NewDataSet/Table/driving_type"/>
<select class="Input" name="driving_type" id="driving_type">
<xsl:for-each select="WebPage/Data/OptReturnData[@OptRetName='GetEmpCarTypeNames']/OptRetData/NewDataSet/Table">
<xsl:choose>
<xsl:when test="contains($temp_driving_type,id)">
<option value="{id}" selected ="selected">
<xsl:value-of select="name"/>
</option>
</xsl:when>
<xsl:otherwise>
<option value="{id}">
<xsl:value-of select="name"/>
</option>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</select>

 

//全局參數

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">

<xsl:template match="/">
<xsl:param name="temp_types" select="WebPage/Data/OptReturnData[@OptRetName='GetEmpCarTypeNames']/OptRetData/NewDataSet"></xsl:param>

<xsl:for-each select="WebPage/Data/OptReturnData[@OptRetName='QueryEmpCarList']/OptRetData/NewDataSet/Rows">
<xsl:if test="(position() mod 2)=0">
<xsl:attribute name="class">Hover Bj</xsl:attribute>
</xsl:if>

<xsl:variable name="temp_driving_type" select="driving_type"/>
<xsl:for-each select="$temp_types/Table">
<xsl:choose>
<xsl:when test="contains($temp_driving_type,id)">
<option value="{id}" selected ="selected">
<xsl:value-of select="name"/>
</option>
</xsl:when>
</xsl:choose>
</xsl:for-each>

</xsl:for-each>

</xsl:template>
</xsl:stylesheet>


個人博客地址:http://www.iwooto.com


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM