Output multiple elements as a JSON array in XSLT

I have an XSL Code as shown below.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes" />

  <xsl:variable name="inlineAddressArray">

  <xsl:variable xmlns:exsl="http://exslt.org/common" name="data" select="exsl:node-set($inlineAddreddArray)" />

    <xsl:value-of select="$data/addrline" />


My expected JSON output should be:


Output that I’m getting

"addressLines": "Home1Home2Home3"

Basically it is just concatenating every element as a single element.

But, I should get three elements separately as shown above.

Can anyone please help me on this? Don’t mind if it’s a silly query. I’m very new to XSLT 🙂

Read more here: Source link