I think you will need a number of templates for this. Firstly, for the array elements, you will need to match elements who have different preceding sibling, but a matching-named following sibling (i.e. they are the first element of the array)
<xsl:template
match="*
[local-name() != local-name(preceding-sibling::*[1])]
[local-name() = local-name(following-sibling::*[1])]" priority="2">
<json:array name="{local-name()}">
<xsl:apply-templates select="self::*" mode="array" />
</json:array>
</xsl:template>
The priority is used here because in the final XSLT, there will be two templates that could potential match the same element, and the array one needs to be chosen first.
Then you can process the elements in the array by outputing the element as an json object, and then matching the following sibling but only if it has the name name.
<xsl:template match="*" mode="array">
<json:object>
<xsl:apply-templates />
</json:object>
<xsl:apply-templates select="following-sibling::*[1][local-name() = local-name(current())]" mode="array" />
</xsl:template>
There would also need to be a template to stop elements in the array being matched independently of the array processing so that the don't get output twice.
<xsl:template match="*[local-name() = local-name(preceding-sibling::*[1])]" />
The other templates needed will be one for string elements, which are elements with no child elements
<xsl:template match="*[not(*)]" priority="1">
<json:string name="{local-name()}">
<xsl:value-of select="." />
</json:string>
</xsl:template>
And finally one to match other elements, which would just be output as objects.
<xsl:template match="*">
<json:object name="{local-name()}">
<xsl:apply-templates />
</json:object>
</xsl:template>
Here is the full XSLT
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:json="http://www.ibm.com/xmlns/prod/2009/jsonx">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<json:object xmlns:json="http://www.ibm.com/xmlns/prod/2009/jsonx">
<xsl:apply-templates />
</json:object>
</xsl:template>
<xsl:template match="*[local-name() != local-name(preceding-sibling::*[1])][local-name() = local-name(following-sibling::*[1])]" priority="2">
<json:array name="{local-name()}">
<xsl:apply-templates select="self::*" mode="array" />
</json:array>
</xsl:template>
<xsl:template match="*" mode="array">
<json:object>
<xsl:apply-templates />
</json:object>
<xsl:apply-templates select="following-sibling::*[1][local-name() = local-name(current())]" mode="array" />
</xsl:template>
<xsl:template match="*[local-name() = local-name(preceding-sibling::*[1])]" />
<xsl:template match="*[not(*)]" priority="1">
<json:string name="{local-name()}">
<xsl:value-of select="." />
</json:string>
</xsl:template>
<xsl:template match="*">
<json:object name="{local-name()}">
<xsl:apply-templates />
</json:object>
</xsl:template>
<xsl:template match="@*|node()[not(self::*)]">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
When applied to your XML, the following is output
<json:object xmlns:json="http://www.ibm.com/xmlns/prod/2009/jsonx">
<json:object name="accounts">
<json:string name="displayOrdinal">0</json:string>
<json:string name="name">String</json:string>
<json:array name="account">
<json:object>
<json:string name="accountNumber">String</json:string>
<json:string name="name">String</json:string>
<json:array name="balance">
<json:object>
<json:string name="balanceAmount">0.0</json:string>
</json:object>
<json:object>
<json:string name="balanceAmount">0.0</json:string>
</json:object>
</json:array>
<json:array name="properties">
<json:object>
<json:string name="displayOrdinal">0</json:string>
</json:object>
<json:object>
<json:string name="displayOrdinal">0</json:string>
</json:object>
</json:array>
<json:array name="usage">
<json:object>
<json:string name="type">String</json:string>
</json:object>
<json:object>
<json:string name="type">String</json:string>
</json:object>
</json:array>
</json:object>
<json:object>
<json:string name="accountNumber">String</json:string>
<json:string name="name">String</json:string>
<json:array name="balance">
<json:object>
<json:string name="balanceAmount">0.0</json:string>
</json:object>
<json:object>
<json:string name="balanceAmount">0.0</json:string>
</json:object>
</json:array>
<json:array name="properties">
<json:object>
<json:string name="displayOrdinal">0</json:string>
</json:object>
<json:object>
<json:string name="displayOrdinal">0</json:string>
</json:object>
</json:array>
<json:array name="usage">
<json:object>
<json:string name="type">String</json:string>
</json:object>
<json:object>
<json:string name="type">String</json:string>
</json:object>
</json:array>
</json:object>
</json:array>
</json:object>
</json:object>