XSLT with test and otherwise

若如初见. 提交于 2019-12-25 00:55:19

问题


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:


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



来源:https://stackoverflow.com/questions/45960995/xslt-with-test-and-otherwise

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!