要转换Submitted_date,received_date和Decision_date的历史记录信息。在下面的xml代码中,包含两个 ms_id 。我想要 ms_no =“ HIPO-18-062.R1” 的article元素中article_set元素中的信息应与
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>
答案 0 :(得分:1)
需要在XSLT中进行的更正。如果要存储元素@ms_no
的属性<article>
的值,则该语句应为
<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]">