XSLT Error Reference

XTDE1490

XSLT 2.0+ XSLT dynamic error
Error message
Cannot write more than one result document to the same URI

Two xsl:result-document instructions resolved to the same output URI — usually a static href inside a loop. Make the href dynamic.

What it means

xsl:result-document writes an output file per invocation. If two invocations produce the same href, the second would overwrite the first — the spec forbids it and Saxon raises XTDE1490.

Common causes

  1. Static href inside xsl:for-each — every iteration writes to the same name:
<!-- Before: every customer writes to out.xml → XTDE1490 -->
<xsl:for-each select="customer">
  <xsl:result-document href="out.xml"></xsl:result-document>
</xsl:for-each>

<!-- After: unique URI per iteration -->
<xsl:for-each select="customer">
  <xsl:result-document href="customer-{@id}.xml"></xsl:result-document>
</xsl:for-each>
  1. Duplicate keys in the datahref="{@id}.xml" with two equal @id values. Deduplicate first (xsl:for-each-group group-by="@id").
  2. Writing to the principal output URI while also producing normal output.

How to fix it

Build the href from something guaranteed unique: a key from the data, position(), or generate-id(). See xsl:result-document for the full syntax and a runnable example.