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
Implement fn:transform #4386
Implement fn:transform #4386
Commits on Aug 3, 2022
Commits on Aug 4, 2022
-
[feature] fn-transform - first functionality
Set up some unit tests from equivalent XQTS tests. Wrap document returned in a map, per spec. Serialize output when requested, borrowing eXist serialization code. Use of stylesheet-params option working Rename unit tests to .xqm Improve transform option type error checking Make badly typed options throw XPTY0004 (type error XPath exception) instead of throwing directly from Java. Handle some of fn:transform “initial-template” param This is part of what is termed call-template invocation, and the transformer’s callTemplate() method is used. Reject call on non-existent source-node Add getStringValue() and toString() to XQueryContext for help in debugging Try harder to resolve stylesheet URIs (in retrospect probably not right yet).
-
-
-
fn:transform - use DocUtils to get stylesheet
and fix up the primary output key in the case where it should not be “output”
-
fn:transform - get xsl:version from simplified stylesheet
XQTS test fn-transform <test-case name="fn-transform-7b"> Uses a stylesheet of the form: <out xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xsl:version='2.0'> <xsl:value-of select='.' /> </out> and we were not picking the stylesheet version from that. Burrow through the element and check for the appropriate NamespaceNode and xsl:version.
-
fn:transform - base URI for transformation
To set the base URI, we need to set the system id for the stylesheet. Then the stylesheet can resolve-uri successfully, and write secondary output documents. Add a result document handler to collect the output for secondary output documents. Result documents now returned to us and we can build tha map with URI and value. Test runner passing document URI where that exists, and we set it up as the system id to the Saxon transformer if it does exist.
-
fn:transform - refactor options, handle raw output
Separate Options class within FnTransform where fully resolved values of options are fetched from the options map once. Called as the first step of eval(), and leaves doing evaluation work based on the options as a cleanly separated task. Raw output request is now handled, and rejected (pre XSLT 3.0) or produced (3.0+) per the spec. Handling raw output and checking for the raw option mutliple times was the indication that we needed to factor out the options processing.
-
-
-
fn:transform - Fix multiple document output
All documents were going to the same builder. Each individual result was consequently the union of all documents.
-
add initial-function param to fn:transform
And a beginning implementation thereof.
-
fn:transform - remove wrong “raw” < 3.0
Erroneously prohibited RAW delivery-format in XSLT version < 3.0 Misreading of the specs
-
fn:transform - Handle some XdmValue conversions
Implement some conversion in the {@link Convert} class. The saxDestination conversion loses type information in some cases, e.g. fn-transform-63 from XQTS has a <xsl:template name='main' as='xs:integer’>. which alongside "delivery-format":"raw" fails to deliver an int. We implement a vestigial Convert class to use the XdmValue generated by the alternative form of call to the transformer with a template, in this case.
-
fn:transform - transformer parameters
Parse and pass template-params to transformer. Parse and pass tunnel-params to transformer, in the same way as template-params. static-params Implement in same way as other param sets. Add a test for serialization-params.
-
fn:transform - initial- mode template conflict
initial-mode and initial-template are conflicting parameters. Create UTs for this conflict. Throw an exception when both are supplied.
-
fn:transform - parameter conflict
source_node and initial_match_selection conflict Return an error if both are supplied. Re-instate raw output of document.
-
fn:transform - attempt at initial-match-selection
refactor options so we have ItemOption where the supplied option must be an item.
-
fn:transform - sequence conversion Saxon to eXist
We need to create a “raw” eXist object from the “raw” Saxon transformation result when delivery-format is “raw”. Add more conversion code to do this for sequences.
-
-
fn:transform - initial-match-selection as document
initial-match-selection can be a document add more unit tests in this area
-
fn:transform - base-output-uri param type
Accept a string as this is often what is provided in practice.
-
fn:transform - string URI convertibility
Several XQTS tests start passing when we do these: A string is a valid base-output-uri for fn:transform A URI is a valid string subtype To predict a later change, a URI should not in general be a valid string subtype, and we will recant this idea, but it works for XQTS tests. The correct non-impactful solution will be to special case allowing and converting a URI when we expect a string in parameters to fn:transform.
-
fn:transform - add initial-mode test (failing)
Start to TDD initial-mode.
-
fn:transform - refactor template invocation flow
Create a sepate invocation object with methods which directly reflect the concept of invocation mode/type that is used in the spec. call-template, call-function and apply-template modes each have their own methods, one of which is selected on invocation of the template according to the options that have been supplied. https://www.w3.org/TR/xpath-functions-31/#func-transform
-
fn:transform - pass initial-mode parameter
initial-mode parameter was not being passed to the invoked transformer.
-
fn:transform - global-context-item parameter
Implement support for global-context-item parameter
-
fn:transform - type of base output uri
Allow this to be supplied as an AnyURIValue or as a StringValue, as both get supplied in practice.
-
-
fn:transform - exactly one source of stylesheet
The parameters stylesheet-location, stylesheet-node, and stylesheet-text cannot occur together.
-
fn:transform - source-node may not be a document
Extract the owning document if this is the case
-
fn:transform - stylesheet-params ignored
Use the values supplied in stylesheet-params. Was previously using a mock testing value.
-
-
fn:transform - resolve base URI in stylesheet-text
While still retaining a correct checksum.
-
fn:transform - refactor, pull out compilation step
Compile the stylesheet as a separate function prior to use.
-
-
-
fn:transform - resolvedStylesheetBaseURI optional
Make the parameter an Optional<>. It makes the intention of testing absence/presence more obvious.
-
[bugfix] fn:transform - correct URI error codes
Some resolver cases manage to pick up a base URI for stylesheet-text when they shouldn’t make that assumption. They then fail to open a non-existent (wrongly generated) filename, and finally return the wrong error. Now, we check for this case in the URI resolver and force the correct error immediately.
-
[bugfix] fn:transform initial-function param
fn:transform call with initial-function specified must also supply function-params. Check this.
-
[bugfix] fn:transform - relative stylesheet
Handle location of stylesheet which is specified as a relative URL. We appeared to only be handling absolute locations of stylesheets, per test fn-transform-25. Also remove some code which didn’t make sense and didn’t appear to be used.
-
[bugfix] fn:transform - global-context-item
Support code for converting a node as part of a document to Saxon was wrong. It was always returning the converted document containing the node. Now count out the “index position” of the original node in all the layers of the document (e.g. 3rd child of 5th child of root) and use that index position to yield the corresponding node in the converted document. Of course, the converted document has the same structure, so the index position works.
-
[testsuite] fn:transform - fn-transform-82e UT
Prepare a correct unit test for the XQTS test fn-transform-82e
-
[testsuite] fn:transform - repair UTs
Up to this point we have created a number of fn:transform UTs that have been used as stepping stones to pass XQTS tests. Some have been left in a non-working state. Triage for the UTs that can be made to work without too much effort, and remove the rest. This leaves us with a handy set of working UTs.
-
[bugfix] fn:transform - cache key was too liberal.
Some of the XQTS tests were getting failures due to falsely matching stylesheets in the stylesheet cache. This change properly distinguishes stylesheets. Where the stylesheet is a document, its base uri is the important part of the cache key. Where the stylesheet is a piece of text, we checksum the text. If the stylesheet doesn’t have a resolved stylesheet base URI or text to checksum, effectively we don’t cache them (well we do, but we use a unique date now()) as an element of the cache, so they will never match another request.
-
-
[feature] fn-transform “serialization-params”
Serialization parameters. Serialization parameter reading/converting code is implemented in its own separate class. The code combines multiple Character maps manually as they are combined naively by supplied parameter combining (new map just overwrites old map in the parameter combination). The spec and XQTS tests require a merged combniation of maps. . Serialization params can be lists so deal with this. cdata-section-elements should be multi-valued.
-
[feature] fn:transform - XSLT compilation errors
Improve error reporting on stylesheet compilation by handling error report exceptions made by the compiler as it progresses, storing these and using the exceptions from the report to be more specific than the standard “compilation didn’t work” exception that is thrown at exit of compilation.
-
[testsuite] fn:transform UT for XQTS transform-68
Add a unit test which confirms that the ‘vendor’ ‘requested-property’ works - which it does not as yet.
-
[feature] fn:transform - requested-properties
Validate “requested-properties” against the system properties of the transformer implementation we are calling (Saxon). fn:transform will proceed if the requested properties match those provided by the transformer. fn:transform will raise an exception if any requested property does not match. No effort is made to deal with or to configure numeric values, so a request for product-version 2.1 will NOT be satisfied by product-version 2.3. Strictly, this behavious conforms to the spec https://www.w3.org/TR/xpath-functions-31/#func-transform, though in some cases it is not terribly helpful.
-
[testsuite] fn:transform UT requested-properties
Implementation of “requested-properties” for fn:transform Add a unit test for the property “supports-namespace-axis”
-
fn:transform - convert XPath error from Saxon call
Initial attempt at returning a correct error code per fn:transform specification and consistent with error codes returned by the Saxon transformer which is used internally. Figure out if an an XPathException from Saxon (a saxon class) or an eXist XPathException was a cause of an exception in Saxon invocation. Return a directly wrapped eXist XPathException as the cause of a new eXist XPathException. Return a wrapped Saxon XPathException as the cause of a new eXist XPathException. Generate/convert/wrap into an appropriate eXist XPathException.
-
[feature] fn:transform post-process function
Read the post-process parameter, and if it is supplied and is a function, apply it to the output of the transformation as a final step in generating the output of fn:transform. The post-process function is applied possibly multiple times, once to the main output and once to every secondary output document. The final result is a map with the same keys as before post processing, but with post processed transformed values replacing transformed values.
-
[bugfix] fn:transform RAW destination for results
Code for xsl:result-document could not create a destination when the output format was RAW. This was an oversight. Allow this to happen.
-
fn:transform - simplify path to invoke transformer
The stages of invocation of the XSLT transformer have been generalised/abstracted enough as we worked through the development that some simplification is now possible. Several cases collapse together, because of the Delivery abstraction that delivers the result in the configured form.
-
fn:transform - fixes to IntelliJ code inspections
Accept changes proposed by IntelliJ code inspections.
-
[bugfix] fn:transform - clean up error handling
When the cause chain for an error contains an XPathException in native eXist, or the Saxon type for an XPathException, work harder to get the correct error code out of that cause, and reflect it in the XPathException ultimately thrown out of FnTransform. This has an effect on the error thrown by XQTS test transform-68, which becomes consistent with the proposed test suite fix here w3c/qt3tests#44
-
fn:transform - refactor into own package
The fn:transform implementation is large, and has accumulated many static and dynamic subclasses of FnTransform. This change creates its own package, and creates several top level classes in this package. The FnTransform module itself becomes a much smaller stub around a call into a Transform object which is part of the new package.
-
fn:transform - tidy up unit tests
Unit tests for fn:transform are mostly composed of convenient UT re-interpretations of the XQTS test suite. There are a lot, so collect them in a subdirectory.
-
[bugfix] fn:transform refactor had multi doc bug
Broken in the refactor. The refactored code was fetching secondary result documents from the wrong delivery object, so the secondary results were non-existent. Fetch from the correct delivery object.
-
-
[bugfix] AnyURI should not be string subtype
This seems to break a number of tests outside of fn:transform. Instead, adapt the option handling for fn:transform to do an explicit check on the case of requiring a string, and supply the StringValue of an atomic value if the value is not of string subtype.
-
fn:transform - remove redundant code
All XQTS tests work within the raw Saxon to eXist conversion code we have, so remove the fallback conversion-via-serialization, which incidentally helps coverage checking.
-
-
-
Commits on Aug 8, 2022
-
-
[bugfix] fn:transform - race condition
XQTS tests were intermittently getting the wrong error message becase we were pullling it as the last error from a shared global error listener (error logger). Make an individual listener for each compilation/request which also side-effects the write to the shared logger.
Commits on Aug 9, 2022
-
fn:transform - some sonarcloud observation fixes
Cleaned up the ones which make sense. Not cleaned up - functions with high complexity where the complexity seems essential to the function. Not cleaned up - old code we have just brushed past lightly, and which sonarcloud has consequently highlighted.
Commits on Aug 10, 2022
-
fn:transform - review feedback
Turn XSLT version number into an XSLTVersion class to be more explicit about precise versions, and to avoid potential float equality issues (2.99999999 != 3.0) Declaration order - member variables first Clarify a commented-out line