Reputation: 33
To transform history information of submitted_date, received_date and decision_date. In below xml code contain two ms_id. I want a information in element of article_set in article element of ms_no="HIPO-18-062.R1" is should be matched view in <history><ms_id ms_no="HIPO-18-062.R1">
XSLT CODE
<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 CODE
<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>
Upvotes: 0
Views: 25
Reputation: 3247
Couple of corrections that need to be done in the XSLT. If you are storing the value of attribute @ms_no
of element <article>
the statement should be
<xsl:variable name="history" select="article_set/article/@ms_no" />
The value in the variable is accessed using $history
so the for-each
loop will change to
<xsl:for-each select="article_set/article/history/ms_id[@ms_no = $history]">
Upvotes: 1