XSLT with test and otherwise

2019-08-29 09:25发布

I have below xslt where ID and LASTNAME are the input parameters. When ID matches the EMPLOYEE_ID in the VW_JAX_EMP_JOB_DEPTRECORDSELECT then set the Last_Name element as s0:PREFERREDLASTNAME otherwise se the input parameter LASTNAME. Below one doesnt work.

 <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>

Can anyone please suggest me ho to set the otherwise tag here.

1条回答
唯我独甜
2楼-- · 2019-08-29 10:05

If I don't missunderstand your intentions I beliveve you are looking for

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

Or if the lastname is more complex

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

See W3school Value of and W3School Copy of

查看更多
登录 后发表回答