2016-11-16 203 views
0

我使用下面的代码的XML标签:变量不打印

<xsl:template name="employmentdates"> 
    <xsl:variable name="empdates"> 
    <xsl:for-each-group select="employment_information/job_information" group-adjacent="emplStatus"> 
     <xsl:if test="current-grouping-key() = 'A'"> 
      <xsl:variable name="Low"> 
       <xsl:for-each select="current-group()"> 
        <xsl:if test="position() = 1"> 
         <xsl:value-of select="start_date"/> 
        </xsl:if> 
       </xsl:for-each> 
      </xsl:variable> 
      <emp_info> 
       <start_date> 
        <xsl:value-of select="$Low"/> 
       </start_date> 
      </emp_info> 
     </xsl:if> 
    </xsl:for-each-group> 
</xsl:variable> 
<xsl:value-of select="$empdates"/> 
</xsl:template> 

在这个我已经定义一个变量empdates和变量我试图做一个小的XML文件。但是,当我试图使用xslt代码<xsl:value-of select="$empdates"/>打印变量empdates 时,它仅打印内容值(日期如:2016-10-20)并缺少xml标记emp_info和start_date。

我期待这样的:

 <emp_info> 
      <start_date>2016-10-20</start_date> 
     </emp_info> 

回答

0

这就是xsl:value-of那样 - 它会创建一个文本节点。你想要xsl:copy-of

+0

谢谢你错过了 – Vicky