WIP: Implement a bit of support for xsl:param and xsl:call-template#123
WIP: Implement a bit of support for xsl:param and xsl:call-template#123bojidar-bg wants to merge 8 commits intoPaligo:mainfrom
Conversation
| copy-0801 | ||
| copy-0901 | ||
| copy-1001 | ||
| copy-1002 |
There was a problem hiding this comment.
Will have to investigate that one...
There was a problem hiding this comment.
Actually—broken in main too!
Investigating a bit, seems like in XSLT, "For backwards compatibility reasons, the pattern node(), when used without an explicit axis, does not match document nodes, attribute nodes, or namespace nodes." (ref), but Xee implement node() the same as in XPath, where it can match absolutely anything.
Something similar seems to be occurring in copy-4502, where match="*" manages to match the document node again.
| conflict-resolution-0801 | ||
| conflict-resolution-0802 | ||
| conflict-resolution-1001 | ||
| conflict-resolution-1101 |
There was a problem hiding this comment.
One of a few tests that exercise exactly what is implemented here 😅
| pub struct ApplyTemplates { | ||
| pub mode: ApplyTemplatesModeValue, | ||
| pub select: AtomS, | ||
| pub named_params: AtomS, |
There was a problem hiding this comment.
Ought to be TemplateNames.
xee-xslt-compiler/src/ast_ir.rs
Outdated
| }) | ||
| } | ||
|
|
||
| fn sequence_constructor_function( |
There was a problem hiding this comment.
Wohoo code duplication!
Unfoturnatelly, due to design decision 1, named xsl:param-s are now part of the argument list of sequence_constructor_function-s, so the main function can no longer be a sequence_constructor_function.
xee-xslt-compiler/src/ast_ir.rs
Outdated
| } | ||
|
|
||
| let parent_var_name = self.variables.current_template_names(); | ||
| let (named_params_atom, bindings) = if pass_all_named && parent_var_name.is_some() { |
There was a problem hiding this comment.
(No clue why parent_var_name.is_some() is needed, as noted around here, // HACK)
63f25aa to
1e8afbb
Compare
|
I feel this draft PR ended up covering too much ground at once, so I'll probably end up closing it, then reimplementing parts of the functionality (global param/variable/function declarations, then named templates, then template params) afresh, now that I have a better idea of where the nasty parts are. @faassen On the topic of global params (and also variables/functions), I'm trying to wrap my head around the best way to implement those. I keep going back and forth between two general ideas:
The main benefit of 1 is that we get to keep the existing code as-is. The main downside is that every single declaration-supplied feature will end up impacting the interpreter and widening the rift between XSLT and XPath. Implementing more of XSLT in terms of the IR, as 2 would imply, feels like it would lead to a more elegant codebase overall; but having major parts of XSLT implemented in Rust probably means a simpler-to-understand codebase. Thoughts? |
|
Closing. This draft PR has served it's purpose for now -- helping me figure out what the hard parts of supporting Params are going to be. |
This is a draft, just wanted to share my work experimenting with
xsl:paramandxsl:with-paramin relation toapply-templates. In addition, I decided to have a go at getting a hack version ofxsl:call-templatein, just to see how many tests it might unfilter.Design decisions taken so far:
xsl:param-s are members of a map, which is subsequently passed as thefirstlast parameter to the internal function declared byxsl:template.HACKHACKPASSTHROUGHcauses parameter pass-through. Will have to figure out a smarter way of figuring out which apply-templates calls should pass their parameters through, but wanted to see how many tests are impacted by that first. (Answer: 4 tests)xsl:call-template, all named templates are registered as brand new modes with an empty predicate pattern, and then executed with some arbitrary context item (here, an empty string). Will have to figure out a better place to store the list of named templates, but wanted to see how many tests are impacted by that first. (Answer: A whooping3236 tests)xsl:param-s at the root level, the main function also takes a list of parameters, like all the functions declared byxsl:template. It currently does not mark them as global (due to the lack of tunnelling or global parameters in general), which means they end up disappearing within a few templates, but again, testing how many tests depend on some very basic support for this. (Answer: 5 tests, the rest also need xsl:variable)