Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?xml version="1.0" encoding="UTF-8"?>
<!--
To run this, download HL7 Version 3 and install it in a folder on your system.
In the Edition2015\domains folder, run the following command:
for /D %d in (*) do for %f in (%d\*.html) do MSXSL %f extractTriggerEvents.xsl spec='%f' >>triggerEvents.csv
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:html="http://www.w3.org/1999/xhtml"
version="1.0">
<xsl:param name="spec" select="'Unknown'"/>
<xsl:output method="text"/>
<xsl:template match="html:html">
<xsl:text>Specification&#9;</xsl:text>
<xsl:text>Interaction&#9;</xsl:text>
<xsl:text>Interaction Name&#9;</xsl:text>
<xsl:text>RIM Class&#x9;</xsl:text>
<xsl:text>RIM Class Code&#x9;</xsl:text>
<xsl:text>Description&#9;</xsl:text>
<xsl:text>Trigger Event&#9;</xsl:text>
<xsl:text>Trigger Name&#9;</xsl:text>
<xsl:text>Message Type&#9;</xsl:text>
<xsl:text>Message Name&#9;</xsl:text>
<xsl:text>Sender Role&#9;</xsl:text>
<xsl:text>Sender Name&#9;</xsl:text>
<xsl:text>Receiver Role&#9;</xsl:text>
<xsl:text>Receiver Name&#xA;</xsl:text>
<xsl:apply-templates
select="//html:td[@class='interact_type'
and string(html:b) = 'Trigger Event']"/>
</xsl:template>
<xsl:template match="text()"/>
<!--
<td class="hmd_code">REPC_MT004000UV01</td>
<td class="hmd_links"><a href="editable/REPC_MT004000UV-NoEdit.html" target="_blank">
-->
<xsl:template name='getRIMStuff'>
<xsl:param name='className'/>
<xsl:variable name='messageFile'
select="//html:tr[html:td[@class='hmd_code'] =
$className]/html:td[@class='hmd_links']/html:a[1]/@href"/>
<xsl:variable name="doc" select="document($messageFile)"/>
<xsl:variable name="act" select="$doc//html:table/html:tr[@class='hmd'][1]"/>
<xsl:value-of select="substring-before(concat($act/html:td[1],'['),'[')"/>
<xsl:text>&#9;</xsl:text>
<xsl:value-of select="$act/following-sibling::html:tr[1]/html:td/html:a/html:b"/>
<xsl:text>&#9;</xsl:text>
</xsl:template>
<xsl:template match="html:td">
<xsl:for-each select="ancestor::html:div[@class='body'][1]">
<xsl:value-of select="$spec"/>
<xsl:text>&#9;</xsl:text>
<xsl:value-of select="preceding-sibling::html:div[@class='header']/html:span[@class='title']/html:a/@name"/>
<xsl:text>&#9;</xsl:text>
<xsl:value-of select="normalize-space(substring-before(concat(preceding-sibling::html:div[@class='header']/html:span[@class='title']/html:a,'('),'('))"/>
<xsl:text>&#9;</xsl:text>
<xsl:call-template name='getRIMStuff'>
<xsl:with-param name="className"
select="html:table[@class='interact']//
html:tr[html:td/html:b = 'Query Response Type']/html:td[3]|
html:table[@class='interact']//
html:tr[html:td/html:b = 'Message Type']/html:td[3]"/>
</xsl:call-template>
<xsl:value-of select="html:table[@class='interact' and
html:tr/html:td/html:b = 'Trigger Event']/preceding-sibling::html:p[1]"/>
<xsl:text>&#9;</xsl:text>
<xsl:value-of select="html:table[@class='interact']//
html:tr[html:td/html:b = 'Trigger Event']/html:td[3]"/>
<xsl:text>&#9;</xsl:text>
<xsl:value-of select="html:table[@class='interact']//
html:tr[html:td/html:b = 'Trigger Event']/html:td[2]"/>
<xsl:text>&#9;</xsl:text>
<xsl:choose>
<xsl:when test="html:table[@class='interact']//
html:tr[html:td/html:b = 'Message Type']">
<xsl:value-of select="html:table[@class='interact']//
html:tr[html:td/html:b = 'Message Type']/html:td[3]"/>
<xsl:text>&#9;</xsl:text>
<xsl:value-of select="html:table[@class='interact']//
html:tr[html:td/html:b = 'Message Type']/html:td[2]"/>
<xsl:text>&#9;</xsl:text>
</xsl:when>
<xsl:when test="html:table[@class='interact']//
html:tr[html:td/html:b = 'Query Response Type']">
<xsl:value-of select="html:table[@class='interact']//
html:tr[html:td/html:b = 'Query Response Type']/html:td[3]"/>
<xsl:text>&#9;</xsl:text>
<xsl:value-of select="html:table[@class='interact']//
html:tr[html:td/html:b = 'Query Response Type']/html:td[2]"/>
<xsl:text>&#9;</xsl:text>
</xsl:when>
</xsl:choose>
<xsl:value-of select="html:table[@class='interact']//
html:tr[html:td/html:b = 'Sender']/html:td[3]"/>
<xsl:text>&#9;</xsl:text>
<xsl:value-of select="html:table[@class='interact']//
html:tr[html:td/html:b = 'Sender']/html:td[2]"/>
<xsl:text>&#9;</xsl:text>
<xsl:value-of select="html:table[@class='interact']//
html:tr[html:td/html:b = 'Receiver']/html:td[3]"/>
<xsl:text>&#9;</xsl:text>
<xsl:value-of select="html:table[@class='interact']//
html:tr[html:td/html:b = 'Receiver']/html:td[2]"/>
<xsl:if test="html:table[@class='interact']//
html:tr[html:td/html:b = 'Query Definition']">
<xsl:text>&#9;</xsl:text>
<xsl:value-of select="html:table[@class='interact']//
html:tr[html:td/html:b = 'Query Definition']/html:td[3]"/>
<xsl:text>&#9;</xsl:text>
<xsl:value-of select="html:table[@class='interact']//
html:tr[html:td/html:b = 'Query Definition']/html:td[2]"/>
</xsl:if>
<xsl:text>&#xA;</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.