Skip to content

feat: support named templates and xsl:call-template - #1

Closed
no-pictures[bot] wants to merge 1 commit into
mainfrom
named-templates
Closed

feat: support named templates and xsl:call-template#1
no-pictures[bot] wants to merge 1 commit into
mainfrom
named-templates

Conversation

@no-pictures

@no-pictures no-pictures Bot commented Jul 19, 2026

Copy link
Copy Markdown

Named templates compile to functions registered by name, so xsl:call-template can invoke one.

How it works

  • ir::Declarations carries the named templates; the declaration compiler compiles each to an InlineFunctionId and registers it in a template_ids map (beside mode_ids), ahead of the rules and main so a call resolves regardless of the caller's position.
  • A template function already takes the context — item, position, size — as parameters, exactly like a matching template.
    xsl:call-template preserves the caller's context, so the call forwards the current context names as the arguments.
    No new instruction is needed: it reuses Closure + Call.

Tests

test_call_named_template (a plain call) and test_call_template_keeps_caller_context (the callee reads the caller's node through local-name()); the existing suite stays green.

Not covered yet

Parameters — xsl:param on the template and xsl:with-param on the call — report as unsupported; a follow-up adds them.

A named template compiles to a function registered under its name.
xsl:call-template invokes it, running the template with the caller's context (item, position, size) as XSLT requires.

Parameters — xsl:param on the template and xsl:with-param on the call — report as unsupported.
@no-pictures
no-pictures Bot force-pushed the named-templates branch from 1a840bd to 08889c1 Compare July 19, 2026 16:10
@no-pictures

no-pictures Bot commented Jul 19, 2026

Copy link
Copy Markdown
Author

Closing in favor of Paligo#145, which implements named templates and xsl:call-template. The named-templates branch stays for reference.

@no-pictures no-pictures Bot closed this Jul 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant