XSLT Error Reference
XTSE0010
Error message
Element xsl:otherwise is not allowed at this location / xsl:X must not appear directly within xsl:YAn XSLT element appears somewhere the language grammar does not allow: wrong nesting, wrong order, or content at the stylesheet top level that must live inside a template.
What it means
The stylesheet is well-formed XML, but an element sits in a position the XSLT grammar forbids. Saxon names the offending element and its location.
Common causes
- Output markup at the top level. Literal result elements (your
<html>,<result>…) must be inside anxsl:template, never directly underxsl:stylesheet. - Wrong order inside
xsl:choose— everyxsl:whenmust come beforexsl:otherwise; nothing else is allowed insidexsl:choose. xsl:paramafter other content. In a template, allxsl:paramdeclarations must be first.xsl:importnot first.xsl:importmust precede every other declaration in the stylesheet.- Instructions used as declarations — e.g.
xsl:value-ofdirectly underxsl:stylesheet.
How to fix it
The message is specific — it tells you which element and where. Typical corrections:
<!-- Before: literal element at top level → XTSE0010 -->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<result/>
</xsl:stylesheet>
<!-- After: wrap it in a template -->
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<result/>
</xsl:template>
</xsl:stylesheet>