xslt - Converting and HL7 segment to XML -
i have xml able generate using hapi libraries , use xsl change format of xml. using following template. current template looks @ obx.5 segment digital value , interprets obx6 (units of measure). trying interpret obx6 when come 1 of clients in style duplicates caret ^
in between (ex: %^%
or ml^ml
). current template ignores able value of segment substring before or after ^
.
<xsl:template match="hl7:obx.6[matches(./../hl7:obx.5, '^\d+(\.\d+)?$') , index-of($percentlist, .) or index-of($mgdllist, .) or index-of($mllist, .) or index-of($mmlist, .) or index-of($mglist, .))]"> <result><xsl:value-of select="./../hl7:obx.5" /></result> <xsl:when test="index-of($percentlist, .)"> <units>%</units> </xsl:when> ... <xsl:when test="index-of($mllist, .)"> <units>ml</units> </xsl:when> <xsl:otherwise> <units><xsl:value-of select="./hl7:ce.1" /></units> </xsl:otherwise> ... </xsl:template>
the result should produce
<result>38.0</result> <units>%</units>
from
<obx.5>38.0</obx.5> <obx.6> <ce.1>%^%</ce.1> </obx.6>
thanks in advance!
use:
tokenize(hl7:ce.1, '\^')[1]
here simple xslt 2.0 - based verification:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/xsl/transform" xmlns:xs="http://www.w3.org/2001/xmlschema"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:template match="obx.6"> <xsl:sequence select="tokenize(ce.1, '\^')[1]"/> </xsl:template> <xsl:template match="text()"/> </xsl:stylesheet>
when transformation applied on following xml document (derived provided xml fragment , made well-formed):
<t> <obx.5>38.0</obx.5> <obx.6> <ce.1>%^%</ce.1> </obx.6> </t>
the wanted, correct result produced:
%
Comments
Post a Comment