Working on linking of some text in input with analyze-string but not able to retrive regex-group(last()) in script.
You can check transform at https://xsltfiddle.liberty-development.net/bnnZVG
As you see, current output
<?xml version="1.0" encoding="UTF-8"?>
<TEST>
<P>Check <Link ID="ID0001">AbC,2013</Link>AbC,2013Marking</P>
<P>Check <Link ID="ID0001">ABc, 2013</Link>ABc, 2013Marking</P>
<P>Check <Link ID="ID0001">ABC 2013</Link>ABC 2013Marking</P>
<P>Check <Link ID="ID0001">ABC</Link>ABCMarking</P>
<P>Check <Link ID="ID0002">BCA,2013</Link>BCA,2013Marking</P>
<P>Check <Link ID="ID0002">bcA, 2013</Link>bcA, 2013Marking</P>
<P>Check <Link ID="ID0002">BCa 2013</Link>BCa 2013Marking</P>
<P>Check <Link ID="ID0002">bcA</Link>bcAMarking</P>
</TEST>
but expected output is
<?xml version="1.0" encoding="UTF-8"?>
<TEST>
<P>Check <Link ID="ID0001">AbC,2013</Link> Marking</P>
<P>Check <Link ID="ID0001">ABc, 2013</Link> Marking</P>
<P>Check <Link ID="ID0001">ABC 2013</Link> Marking</P>
<P>Check <Link ID="ID0001">ABC</Link> Marking</P>
<P>Check <Link ID="ID0002">BCA,2013</Link> Marking</P>
<P>Check <Link ID="ID0002">bcA, 2013</Link> Marking</P>
<P>Check <Link ID="ID0002">BCa 2013</Link> Marking</P>
<P>Check <Link ID="ID0002">bcA</Link> Marking</P>
</TEST>
Thanks in Advance
Which value do you expect from calling
last()inside ofxsl:analyze-string? If you look at the last paragraph in https://www.w3.org/TR/xslt-30/#element-analyze-string it says:So as
last()returns the context size it should be equal to the number of matching and non-matching substrings.I realize this is not quite an answer but it is too long to be used as a comment. You might also want to edit your question and tell us what the XSLT you have linked to is supposed to achieve in plain words, then we might be able to help suggest an appropriate XSLT solution.
Also note that XSLT 3 with XPath 3 has an
analyze-stringfunction which returns an XML structure with the matches and groups so processing/consuming that might help you to extract the contents you want:https://xsltfiddle.liberty-development.net/bnnZVG/2 gives