apple/pkl · error · VmException
elementNotSupportedHere
elementNotSupportedHere
Error message
elementNotSupportedHere
What it means
When rendering XML, a `Dynamic` object that was recognized as an XML element (or inline value) appeared in a position where the renderer does not support it. The renderer throws `elementNotSupportedHere` with the offending value instead of emitting invalid XML.
Source
Thrown at pkl-core/src/main/java/org/pkl/core/stdlib/xml/RendererNodes.java:183
@Override
public void visitPair(VmPair value) {
cannotRenderTypeAddConverter(value);
}
@Override
public void visitRegex(VmRegex value) {
cannotRenderTypeAddConverter(value);
}
@Override
public void visitIntSeq(VmIntSeq value) {
cannotRenderTypeAddConverter(value);
}
@Override
protected void startDynamic(VmDynamic value) {
if (isXmlElement(value)) {
throw new VmExceptionBuilder()
.evalError("elementNotSupportedHere")
.withProgramValue("Value", value)
.build();
}
}
@Override
public void startTyped(VmTyped value) {
if (isXmlInline(value)) {
throw new VmExceptionBuilder()
.evalError("inlineNotSupportedHere")
.withProgramValue("Value", value)
.build();
}
}
// No-op for XML
@OverrideView on GitHub (pinned to f3efcbfc9b)
Solutions
- Move the element-shaped Dynamic into a position rendered as XML content (e.g. a `content` Listing)
- If it is data, not XML, rename its `name` member or use a plain object so it is not detected as an XmlElement
- Render only scalar values in attribute positions
- Check the pkl-xml library version and supported nesting rules
Example fix
// before
person { name = xmlElement("a", ...) } // element in attribute position
// after
person { content { xmlElement("a", ...) } } Defensive patterns
Strategy: validation
Validate before calling
// Pkl: only place XmlElement-shaped objects where the renderer starts elements
function looksLikeElement(d: Dynamic): Boolean = d.hasProperty("name") && d.hasProperty("content") Type guard
function isScalar(v: Any): Boolean = v is String || v is Boolean || v is Number || v is Null
Prevention
- Nest element-shaped objects only inside content positions
- Keep scalar-only values in attribute positions
- Follow pkl-xml library nesting conventions
When it happens
Trigger: A `Dynamic` value satisfying `isXmlElement` (has `name`/`attributes`/`content` members) is visited at a position in the XML output where an element cannot be started, e.g. as an attribute value or inside a property that is not rendered as element content.
Common situations: See trigger scenarios.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- inlineNotSupportedHere
- typeMismatch
- Maps containing non-String keys cannot be rendered as JSON.
- Values of type `TypeAlias` cannot be rendered as Properties.
- Values of type `Regex` cannot be rendered as Properties. Val
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/3e111e149e89efba.
Report an issue: GitHub.