-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
We should be using XPath map/array handling rather than serializing to/from XML #239
Comments
I'll be intrigued to see if this makes any difference. I must admit that I've never really understood what happens when you use method="json" and what the consequences of |
I'm going to experiment with this in branch iss239-json |
I have now done this in the iss239-json branch, but my tests are so far inconclusive. In my local copy, I've added the
I've attached the report for the test set to this ticket (with the respective branch names in the file). I'm going to test now with just the English TEI guidelines to see if those results are more conclusive. |
It's not making much difference. Does it make for more human-readable, maintainable code in your view? |
I think it is, but at the same time, |
In
json.xsl
, we create stash the created map in a variable that are then serialized usingxml-to-json()
. E.g.:staticSearch/xsl/json.xsl
Lines 204 to 209 in c1dbd48
That map is not a
map{}
in the XPath sense, but an XML structure in the JSON namespace:staticSearch/xsl/json.xsl
Lines 322 to 354 in c1dbd48
However, there's no need to do that since we could use
<xsl:map>
and set the output method tojson
:I'm not sure if there was a reason why we didn't do this in the first place, but I can't think of any reason not to do so at this point. It may improve performance slightly as well as possibly lessen memory use. (There's some indication that constructing sequences in the result-document allows Saxon more leverage when it comes to releasing memory; I don't imagine it would be significant, but worth testing anyway.) In any case, it's a bit cleaner and feels a bit better to use built-in functions.
The only annoying bit is that there is no such thing (yet) as an
<xsl:array>
instruction[1], so we would still need to stash all of the context arrays in a variable in order to create an array using thearray{}
constructor, but that's simple enough.--
[1]: They are proposing such a thing for XSLT 4.0: https://www.saxonica.com/html/documentation11/xsl-elements/array.html
The text was updated successfully, but these errors were encountered: