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">
<addrline>Home1</addrline>
<addrline>Home2</addrline>
<addrline>Home3</addrline>
</xsl:variable>
<xsl:variable xmlns:exsl="http://exslt.org/common" name="data" select="exsl:node-set($inlineAddreddArray)" />
<addressLines>
<xsl:value-of select="$data/addrline" />
</addressLines>
</xsl:stylesheet>
My expected JSON output should be:
"addressLines":"[Home1,Home2,Home3]"
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 :)
xslt-2.0when you are obviously using (or rather misusing) XSLT 1.0? And what is the point of defining a variable with hard-coded elements, when you need a string?exsl:node-set()in XSLT 2.0. And your output is XML, not JSON, so it's not clear how JSON comes into this at all."addressLines":"[Home1,Home2,Home3]"doesn't look like JSON. Also, your XSLT outputs XML, do you integrate XSLT in some other tool chain where that XML is being converted to JSON? In that case you need to name the tool chain.