XSLT 1.0 is designed to convert XML to XML, text or HTML. Therefore, the input must be valid XML. Although this could be technically done in your example by including your input with some root xml tag (e.g. <root> ) and avoiding some characters (e.g. < ), it still requires you to parse the lines in XSLT - for which XSLT is not intended. This is not impossible, but it will be very slow (and tedious to write).
You can first convert your input file to a valid xml (e.g. with perl, awk, sed, python, ...) to get something like:
<root> <definition> <item>AGENT_REF</item> <item>ADDRESS_1</item> <item>ADDRESS_2</item> ... </definition> <data> <line> <item>12345_ALZ57065V</item> <item/> <item>Spacious 3 bedroom villa with pool in Vale da Telha</item> <item/> ... </line> <line> ... </line> ... </data> </root>
and then converted it with XSLT to the desired result.
OTOH, when data is already being processed by a string processing language (like perl), its only very small extra step is to directly create the desired XML without using XSLT at all.
source share