File: Data.xml
title 1
A
B
C
D
E
F
File: Transform.xslt
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:local="local-functions.uri" exclude-result-prefixes="xs local"
version="2.0">
select="for $w in distinct-values(//LINE)
return upper-case($w)" />
test="local:is-character($words[1]) and
lower-case($words[2]) = 'and' and
local:is-character($words[3])">
separator=" " />
select="local:split(.)" />
Output: