Flesh out the XSLT 1.0 functions in the XML examples#333
Merged
jcflack merged 3 commits intoREL1_6_STABLEfrom Nov 22, 2020
Merged
Flesh out the XSLT 1.0 functions in the XML examples#333jcflack merged 3 commits intoREL1_6_STABLEfrom
jcflack merged 3 commits intoREL1_6_STABLEfrom
Conversation
Although XSLT 1.0 is very much like punishment when a modern version is available with Saxon, it does have the advantage of being included in Java rather than a large separate download. Now that it's usable, the example functions may as well be polished a bit (say, by making the uninteresting-but-for-testing 'how' parameters optional, and accepting an 'adjust' parameter) and made suitable for day-to-day use. One useful feature of the XSLT 1.0 transformer is the ability to indent XML: great for readability, not available in core PostgreSQL, and easy to do here. It doesn't require any particular transformation defined; the default identity transform from the no-argument TransformerFactory.newTransformer is enough. So make it possible to pass null for transformName for a plain identity transform, and add optional indent and indentWidth direct arguments to make it simple. This can also serve as an example to clarify just how one gets xalan to indent, as the details are subtle enough to have needed hashing out on Stack Overflow [1]. [1] https://stackoverflow.com/a/60610218/4062350
The ability in xalan to call out to Java methods can be extremely useful in the otherwise very limited XSLT 1.0 dialect. But it sorely needs an example, being fiddly enough to get right the first time that newcomers might otherwise flee in frustration.
It's tedious to duplicate them in an @SQLAction GRANT or REVOKE. Maybe that indicates it would be useful to add grant/revoke support in annotations someday.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
My usual advice to anyone considering XSLT 1.0 is "run away!" because it is so primitive and limiting compared to the later versions. And certainly what's possible by downloading Saxon and using XSLT 3 or XQuery 3.1 is far and away preferable to struggling with XSLT 1.0.
Its one advantage is that it is directly included in Java with no need of a large, separately-downloaded jar, and that's enough to make it useful if there's some simple transformation to be done that doesn't require the big guns. Another redeeming feature of Java's XSLT support is that it can call out to Java methods, often allowing a way around the otherwise crippling limitations of strict XSLT 1.0.
So, it is worthwhile to take the existing example methods demonstrating the XSLT 1.0 support and give them a little further polishing to make them convenient for more serious use.