XSLT xsl:element With a Computed Name Fails Without a Namespace Resolver
What does "com.capeclear.mediation.MediationException: Xslt step" mean in Workday Studio?
An xsl:element instruction is taking its element name from a variable at run time, and that value carries a namespace prefix. The processor has no way to turn the prefix into a namespace at that point, so it refuses to build the element. Desktop XML editors resolve names differently, which is why the same stylesheet can pass locally.
Quick fix
Add a namespace attribute to the xsl:element instruction giving the target namespace URI directly, or strip the prefix off the computed name with substring-after so an unprefixed name is produced.
Permanent fix
Never let a computed element name carry a bare prefix. Work out the local name and the namespace URI as two separate values and pass both to xsl:element. Validate stylesheets against the Studio runtime rather than only in a desktop editor, because the two differ in how they resolve names.
Troubleshooting
- Find the xsl:element whose name attribute is an expression rather than a literal. Only a computed name can produce this failure, so a stylesheet with no computed names is not the cause.
- Print the computed value immediately before the element is created. If it contains a colon it is a prefixed QName and needs a namespace in scope.
- Check whether that prefix is declared on an ancestor element inside the stylesheet itself. A prefix declared only in the source document or in a config file is not in scope for the stylesheet.
- Decide whether the output element genuinely needs a namespace at all. Mappings often copy a prefix across by accident when the target format wants a plain unprefixed name.
- If the namespace really is required, supply it explicitly on the instruction instead of relying on prefix resolution.