XSLT与测试和否则

时间:2017-08-30 12:52:57

标签: xml if-statement xslt

我在xslt以下,其中ID和LASTNAME是输入参数。当ID与VW_JAX_EMP_JOB_DEPTRECORDSELECT中的EMPLOYEE_ID匹配时,将Last_Name元素设置为s0:PREFERREDLASTNAME,否则将输入参数LASTNAME设置为。下面一个不起作用。

 <xsl:template name="GetLastNameVW_JAX_EMP_JOB_DEPT"> 
   <xsl:param name="ID" />
   <xsl:param name = "LASTNAME" />
   <xsl:element name="Last_Name">
     <xsl:choose>
       <xsl:when test="//s0:VW_JAX_EMP_JOB_DEPTRECORDSELECT[s0:EMPLOYEE_ID = $ID]/s0:PREFERREDLASTNAME">
         <xsl:value-of select="//s0:VW_JAX_EMP_JOB_DEPTRECORDSELECT[s0:EMPLOYEE_ID = $ID]/s0:PREFERREDLASTNAME" />
       </xsl:when>
       <xsl:otherwise> LASTNAME
       </xsl:otherwise>
     </xsl:choose>
   </xsl:element> 
 </xsl:template>

有人可以建议我在这里设置其他标签。

1 个答案:

答案 0 :(得分:1)

如果我不理解你的意图我相信你正在寻找

<xsl:value-of select="$LASTNAME"/>

或者如果姓氏更复杂

<xsl:copy-of select="$LASTNAME"/>

请参阅W3school Value ofW3School Copy of