I am a beginner to xslt. I am trying to search a long string for value in my case "EMRUPI", and I need to extract the ID prior and populate another field. I'm using the "substring-before" function
i can not seem to extract the value, it returns NULL
This is the data:
PID|1|12345^^^ABCMRN^MRN^|678988^^^DEFMRN^MRN^~111111^^^GHIMRN^MRN^~7777777^^^EMRUPI^CMRN^||
I basically want to find in the PID3 segment (PID3 is the data after the 3rd pipe "|") the text 'EMRUPI' and grab the id prior to that '7777777'. I want to save it in a variable eg $EMRUPI and put it into PID4 segment which is what i am trying to do here:
here is the script i wrote:
<PID>
<F3>
<xsl:variable name="EMRUPI" select="substring-before(name(),'EMRUPI')" />
<xsl:value-of select="substring-before(name(),'EMRUPI')" />
<L1.1.1><xsl:value-of select="$EMRUPI"/></L1.1.1>
</F3>
<F4><L1.1.1><xsl:value-of select="$EMRUPI"/></L1.1.1></F4>
</PID>