Search code examples
xmlxsltxslt-2.0

Need help XSLT 2.0


Want to Split the word using XSLT

Input is

<ID>ABCD-1234-6547</ID> 

and the output should look like

<ID>ABCD-1234</ID>

I want XSLT code for the above-summarized problem.

I did not write code yet.

The output should look like

<ID>ABCD-1234</ID>

Solution

  • You could use:

    <xsl:value-of select="tokenize(ID, '-')[position() le 2]" separator="-"/>
    

    Demo: https://xsltfiddle.liberty-development.net/ej9EGcF/1


    Or perhaps it's sufficient to do simply:

     <xsl:value-of select="substring(ID, 1, 9)"/>