title: Converting and HL7 segment to XML
body: <p>i have an XML that we were able to generate using HAPI libraries and use XSL to change the format of the XML.  I am using the following template. The current template looks at the OBX.5 segment for a digital value and then interprets the OBX6 (units of measure).  However I am trying to also interpret the OBX6 when they come from one of the clients in a style as duplicates with the caret <code>^</code> in between (ex: <code>%^%</code> or <code>mL^mL</code>).  My current template ignores this but I would like to be able to get the value of the segment substring before or after the <code>^</code>. </p>
  
  <pre><code>&lt;xsl:template match="hl7:OBX.6[matches(./../hl7:OBX.5, '^\d+(\.\d+)?$') and index-of($percentList, .) or index-of($mgdlList, .) or index-of($mlList, .) or index-of($mmList, .) or index-of($mgList, .))]"&gt;
      &lt;result&gt;&lt;xsl:value-of select="./../hl7:OBX.5" /&gt;&lt;/result&gt;
          &lt;xsl:when test="index-of($percentList, .)"&gt;
              &lt;units&gt;%&lt;/units&gt;
          &lt;/xsl:when&gt;
  ...
          &lt;xsl:when test="index-of($mlList, .)"&gt;
              &lt;units&gt;ml&lt;/units&gt;
          &lt;/xsl:when&gt;
  
          &lt;xsl:otherwise&gt;
              &lt;units&gt;&lt;xsl:value-of select="./hl7:CE.1" /&gt;&lt;/units&gt;
          &lt;/xsl:otherwise&gt;
  ...
  
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>The result should produce </p>
  
  <pre><code>            &lt;result&gt;38.0&lt;/result&gt;
              &lt;units&gt;%&lt;/units&gt;
  </code></pre>
  
  <p>from</p>
  
  <pre><code>                &lt;OBX.5&gt;38.0&lt;/OBX.5&gt;
                  &lt;OBX.6&gt;
                      &lt;CE.1&gt;%^%&lt;/CE.1&gt;
                  &lt;/OBX.6&gt;
  </code></pre>
  
  <p>Thanks in advance!</p>