1

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>

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
alicia
  • 11
  • 1
  • This is not trivial to do in XSLT 1.0. Which XSLT 1.0 processor will you be using? You could really use some extension functions here, if your processor supports them. – michael.hor257k Apr 16 '19 at 07:08
  • If you don't know, find out - see: https://stackoverflow.com/questions/25244370/how-can-i-check-which-xslt-processor-is-being-used-in-solr/25245033#25245033 – michael.hor257k Apr 17 '19 at 21:33
  • Hi Michael im using definately XLST 1.0. Could you let me know what you suggest with extension functions, i am not sure what you mean here. Any advice is really helpful. thanks! – alicia Apr 30 '19 at 00:21
  • Hi Michael, i am reading now about extention functions but in the meantime is there any reason why my code is not working? it would be quicker to get this working or if there is another inbuilt function i could use? thanks – alicia Apr 30 '19 at 00:35
  • Your code makes no sense to me, I am afraid (especially your use of the `name()` function). It would be quicker (for me anyway) if you answered my question. – michael.hor257k Apr 30 '19 at 06:42
  • Another thing that may help here is an explanation of the delimiters used by your input string. – michael.hor257k Apr 30 '19 at 07:02

0 Answers0