xsl:result-document writes a secondary result; href is an attribute value template resolved against the -o: location, and serialization (method, indent) can differ per file. Run xslt3 -s:booknest-catalog.xml -xsl:split.xsl -o:out/main.txt, then print two of the three files:
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"
expand-text="yes">
<xsl:template match="/catalog">
<xsl:for-each-group select="book" group-by="supply/availability">
<xsl:result-document href="{current-grouping-key()}.xml" indent="yes">
<books status="{current-grouping-key()}">{current-group()/identifier}</books>
</xsl:result-document>
</xsl:for-each-group>
<xsl:result-document href="index.json" method="json" indent="yes">
<xsl:sequence select="map { 'count': count(book),
'skus': array { book/identifier ! string() } }"/>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>Output
<?xml version="1.0" encoding="UTF-8"?>
<books status="out-of-stock">BN-0003</books>
{
"count": 6,
"skus": [ "BN-0001", "BN-0002", "BN-0003", "BN-0004", "BN-0005", "BN-0006" ]
}The empty principal result wrote no main.txt. Writing one URI twice fails (XTDE1490), so this is a safe partitioned write, like Spark 129 's (Batch Processing with Apache Spark).