如何仅转换特定属性值

  • 本文关键字:属性 何仅 转换 xslt-1.0
  • 更新时间 :
  • 英文 :


转换提交日期、接收日期和决策日期的历史信息。在下面的xml代码中,包含两个ms_id。我想要ms_no="HIPO-18-062.R1">的article_set的元素中的信息应该与<历史>lt;ms_id ms_no="HIPO-18-062.R1">

XSLT代码

<p><table border="1" cellpadding="10px">
<xsl:variable name="history" select="article_set/article[@ms_no]" />
<xsl:for-each select="article_set/article/history/ms_id[@ms_no='@history']"><tr><td colspan="3" align="center"><b>History Information</b></td></tr>
<tr><td><b>Submitted Date</b></td><td colspan="2"><xsl:value-of select="submitted_date"/></td></tr>
<tr><td><b>Received Date</b></td><td colspan="2"><xsl:value-of select="received_date"/></td></tr>
<tr><td><b>Decision Date</b></td><td colspan="2"><xsl:value-of select="decision_date"/></td></tr></xsl:for-each>
</table></p>

XML代码

<article_set dtd_version="4.23">
<article export_date="2018-07-16 00:00:00.0" external_id="" lang="EN" ms_no="HIPO-18-062.R1" rev="1">
<history>
<ms_id ms_no="HIPO-18-062.R1">
<rev_id>1</rev_id>
<submitted_date>
<year>2018</year>
<month>06</month>
<day>20</day>
<hour>14</hour>
<minute>50</minute>
<second>01</second>
<time_zone>(GMT-05:00) Eastern Time (US & Canada)</time_zone>
</submitted_date>
<received_date>
<year>2018</year>
<month>05</month>
<day>01</day>
<hour>11</hour>
<minute>50</minute>
<second>00</second>
<time_zone>(GMT-05:00) Eastern Time (US & Canada)</time_zone>
</received_date>
<decision_date>
<year>2018</year>
<month>07</month>
<day>13</day>
<hour>15</hour>
<minute>23</minute>
<second>28</second>
<time_zone>(GMT-05:00) Eastern Time (US & Canada)</time_zone>
</decision_date>
</ms_id>
<ms_id ms_no="HIPO-18-062">
<submitted_date>
<year>2018</year>
<month>05</month>
<day>01</day>
<hour>11</hour>
<minute>50</minute>
<second>00</second>
<time_zone>(GMT-05:00) Eastern Time (US & Canada)</time_zone>
</submitted_date>
<received_date>
<year>2018</year>
<month>05</month>
<day>01</day>
<hour>11</hour>
<minute>50</minute>
<second>00</second>
<time_zone>(GMT-05:00) Eastern Time (US & Canada)</time_zone>
</received_date>
<decision_date>
<year>2018</year>
<month>05</month>
<day>23</day>
<hour>18</hour>
<minute>41</minute>
<second>15</second>
<time_zone>(GMT-05:00) Eastern Time (US & Canada)</time_zone>
</decision_date>
</ms_id>
</history>
</article>
</article_set>

需要在XSLT中进行的几项更正。如果要存储元素<article>的属性@ms_no的值,则语句应为

<xsl:variable name="history" select="article_set/article/@ms_no" />

使用$history访问变量中的值,因此for-each循环将变为

<xsl:for-each select="article_set/article/history/ms_id[@ms_no = $history]">

相关内容

  • 没有找到相关文章

最新更新