I've got the following xml:
<section>
<templateId root="2.16.840.1.113883.10.20.22.2.4" />
<text>
<list listType="ordered">
<item>9/18/2013 - Weight - 125 lbs</item>
<item>9/18/2013 - Blood Pressure - 120/80 mm Hg</item>
<item>9/18/2013 - BMI - 19 98</item>
</list>
</text>
</section>
I need to have the html output appear as the following:
<table>
<tr>
<td>9/18/2013</td>
<td>Blood Pressure - 120/80</td>
<td>Weight - 125lbs</td>
<td>BMI - 19</td>
</tr>
</table>
I have the following key set up in my xsl file:
<xsl:key name="vs_times" match="//hl7:section[hl7:templateId/@root='2.16.840.1.113883.10.20.22.2.4']/hl7:text/hl7:list/hl7:item" use="substring-before(., ' - ')"/>
This is to get the date. In my xml, there COULD be more than one set of dates (but at most two) and the second date option would be another row in the table example above.
This is my xsl template information to output:
<xsl:template match="hl7:section[hl7:templateId/@root='2.16.840.1.113883.10.20.22.2.4']">
<div style="padding: 5px; border-top: 1px solid #000000;">
<table border="0" cellspacing="0" cellpadding="1" width="100%">
<xsl:for-each select="hl7:text/hl7:list/hl7:item[generate-id(.)=generate-id(key('vs_times', substring-before(., ' - ')))]">
<tr>
<td style="width: 76px;">
<xsl:value-of select="substring-before(., ' - ')" />
</td>
<xsl:variable name="values" select="key('vs_times', substring-after(., ' - '))"/>
<td style="width: 180px; padding-left: 3px;">
<xsl:choose>
<xsl:when test="substring-before($values, ' - ') = 'Blood Pressure'">
<span style="font-weight: bold;">Blood Pressure: </span>
<xsl:value-of select="substring-after($values, ' - ')"/>
</xsl:when>
<xsl:otherwise>
 
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:for-each>
</table>
</div>
</xsl:template>
(this is just a snippet. if I can get the one table cell to show up for the blood pressure, then I can duplicate that for the other list items). The issue I'm having is that the date is showing up without issue. However, the next table cell is not showing up. I don't know if I'm referencing my key wrong or if I'm referencing the value to show wrong.
Thanks
It looks like you have
substring-after
where you should havesubstring-before
:should be:
And this should have
substring-after
:Also, you'll need to iterate through the items in
$values
(preferably with templates rather thanfor-each
), but it seems like you might already know that. Something like this: