exist icon indicating copy to clipboard operation
exist copied to clipboard

Implement fn:transform

Open adamretter opened this issue 2 years ago • 6 comments

Implements the fn:transform function specification

The transform function is complex, so we have chosen to structure it as a number of top level classes in their own package, org.exist.xquery.functions.fn.transform which are invoked by the main org.exist.xquery.functions.fn.FnTransform class.

The implementation relies on the Saxon XSLT processing library to compile referenced stylesheet(s).

In highly simplified terms, the implementation:

  • Reads and checks all the parameters/options to the function
  • Invokes Saxon to compile the identified stylesheet
  • Retrieves a transformer from the compilation
  • Figures out which form of application of the stylesheet is required
  • Constructs (a) delivery object(s) to build output according to the requested delivery format
  • Calls Saxon again (the transformer this time) applying the stylesheet to the input
  • Builds the result map using the contents of the delivery objects, and returns it

Unit Tests

A number of unit tests have been added, driven by the an attempt to test the same functionality as some of the individual XQTS tests efficiently during development. These tests do not provide complete coverage of the features of fn:transform, and the XQTS tests should be considered as the truth.

XQTS Tests

The goal of the development of fn:transform has been to pass all the tests in the fn-transform test set of XQTS tests for transformation.

The tests are run with the eXist XQTS Runner

  • The test fn-transform-68 currently fails. We are satisfied that the behaviour exhibited by our code is correct, and that the test is deficient Issue

  • All other tests from the fn:transform test set pass, except for 4 tests which are not run because they require features that eXist-db does not support (e.g. custom schema types in XQuery) .


This open source contribution to the eXist-db project was commissioned by the Office of the Historian, U.S. Department of State, https://history.state.gov/.

adamretter avatar May 12 '22 18:05 adamretter

Be careful, you copied the W3C's "FOXT0001" error code too many times, I'm afraid ;-)

brihaye avatar May 12 '22 19:05 brihaye

Thanks @brihaye I have fixed that now.

adamretter avatar May 12 '22 19:05 adamretter

@alanpaxton Thank you for this PR and the truly Herculean effort that went into implementing this complex function!

joewiz avatar Aug 09 '22 17:08 joewiz

it would be nice if we could get of the old unmaintained xalan lib.....

dizzzz avatar Aug 09 '22 19:08 dizzzz