Java: Is it possible (and practical) to build a JSLT Expression programmatically rather than from String? #317
Replies: 1 comment
-
Regarding your need first, if the mapping has a simple key you could generate a JSON dictionary using Jackson in-memory to represent the mapping. You could then pass this as a parameter to the mapping, and access the dictionary using That way you could have a simple JSLT and not pollute it with all the generated data. The mapping could then easily be built in-memory and also stored to plain JSON. Regarding your actual questions: (A) There is a way to do it, because this is what the JSLT parser does. However, you then need to use internal classes. I'm not sure it's a good idea, particularly not given your question (B). (B) I'm afraid there is only limited support for this at the moment. It's something that definitely could be built. Patches to add this support would be welcome. However, if you need (B), why not generate the JSLT as a string right away, and avoid entangling yourself in the JSLT internals? I'm not sure building the expression as an object would necessarily be any nicer. |
Beta Was this translation helpful? Give feedback.
-
I've got a series of mappings from a source document to a target document stored as rows in a database, and I'd like to have my server build a JSLT transformation/expression from them which I can then use many times.
(A) Is there a way to make a
com.schibsted.spt.data.jslt.Expression
programmatically rather than from a file/string?(B) Can I take an Expression object and convert it to a String which I can store and then re-compile into an Expression at a later date?
Beta Was this translation helpful? Give feedback.
All reactions