[Dev6] fix XSLT imports - #6544
Conversation
In order to build develop-6.x.x we need to downgrade IzPack to the latest version that does not have the transitive dependency on org.pushing-pixels:radiance-theming(-extras) v7.5.0 Because that requires Java 9 to compile. This is likely an unintentional change or bug upstream.
Passing persistent nodes from XQuery to fn:transform as parameters works now. - dereference NodeProxy objects in Convert.of(Sequence) - match both persistent and in-memory Documents in Convert.ofNode(Node) Backport of fddbfd3
refs eXist-db#6065 With this PR applied the shared document builder from the parent XqueryContext is never used. As a result two calls to fn:transform within the same context no longer corrupt each others return values. The actual root-cause of what is described in the linked gist: https://gist.github.com/line-o/4731ed367f437be9cd036b152a18d340
fn:transform did not resolve relative URIs against the database: relative xsl:include/xsl:import hrefs in stored stylesheets, and a relative stylesheet-location, would not resolve the way fn:doc and transform:transform already do. In particular a declared base-uri pointing at a collection without a trailing slash could lose its last path segment during resolution. - Add Transform.newFnTransformURIResolver, leveraging the existing XsltURIResolverHelper.getXsltURIResolver. It is installed in two places: on the XsltCompiler (resolves relative xsl:include/ xsl:import at compile time) and on the Xslt30Transformer's controller (resolves runtime lookups such as fn:doc()/document() inside the stylesheet). - Transform.databaseBaseURI derives the base to resolve against: the stylesheet's own resolved base URI if it's a database location (isDatabaseURI), otherwise falling back to the querying module's location in the database when the stylesheet was built in-memory (stylesheet-node/stylesheet-text with no explicit stylesheet-base-uri). - New error path: stylesheet-text with a relative href and no stylesheet-base-uri now raises XTSE0165 instead of resolving incorrectly. - Options.resolveStylesheetLocation now encapsulates discerning relative/absolute/external stylesheet-location values and returns the Tuple directly, rather than that logic living in Options.getStylesheet. XQSuite tests added in fnTransform5052.xqm. refs eXist-db#5052 NOTE: This fixes the relative imports in XSLT for develop-6; the issue will be closed once the patch is forward-ported to develop.
|
@line-o we discovered a bug in izpack 5.2.3 during the beta release, not present in 5.2.2 if you have to downgrade we might want to go down two versions. I m a bit at a loss how this pr relates to the in-flight upstream PRs touching upon this code area. |
| <izpack.version>5.2.4</izpack.version> | ||
| <!-- NOTE: IzPack 5.2.4 pulls in radiance-theming 7.5.0 which requires Java 9+, | ||
| 5.2.3 is the last release whose dependencies are all Java 8 compatible --> | ||
| <izpack.version>5.2.3</izpack.version> |
There was a problem hiding this comment.
I will open an issue upstream
|
|
exist 6.4.1 was released with Izpack 5.2.3 -> I think you are referring to 5.2.5 |
|
#6531 adresses ✅ Compile-time URI resolution for xsl:import/xsl:include via URIResolution.CompileTimeURIResolver Missing from #6531 ❌ Runtime URI resolution for document() calls within the XSLT (at transform execution time) What I will closely look at is the URI resolution logic in Options.java. |
… builder isolation Fixes eXist-db#5052 and eXist-db#6065 by porting key changes from develop-6.x.x: 1. Document builder isolation (Delivery.java): - Always use fresh MemTreeBuilder for transform results - Prevents corruption when multiple fn:transform calls occur in same context - Fixes issue eXist-db#6065 where concurrent transforms corrupted each other's output 2. Persistent node handling (Convert.java): - Handle persistent NodeProxy nodes by dereferencing to underlying DOM - Enables passing database-stored nodes as stylesheet parameters - Checks Document interface instead of specific implementation 3. Enhanced stylesheet location resolution (Options.java): - Return Tuple2<String, Source> to track actual resolved location - Sets SystemId on DOMSource for proper relative URI resolution - Fallback resolution for relative URIs using RFC 3986 + database resolution 4. Runtime URI resolution (Transform.java): - Install runtime URI resolver on XSLT controller - Enables fn:document() calls within stylesheets to resolve against database - Integrates with existing URIResolution.CompileTimeURIResolver - Adds helper methods: newFnTransformURIResolver(), databaseBaseURI(), isDatabaseURI() - Supports xsl:include/xsl:import resolution for stylesheets stored in database 5. Build configuration: - Downgrade IzPack to 5.2.3 (5.2.4+ requires Java 9+) Test coverage: - fnTransform5052.xqm: Tests relative xsl:include/import and stylesheet-location resolution - fnTransform6065.xqm: Tests persistent nodes as stylesheet parameters Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
duncdrum
left a comment
There was a problem hiding this comment.
LGTM, one minor nitpick about the inlined xquery lines in fnTransform6065.xq,
| "stylesheet-params": map { | ||
| xs:QName("v"): doc($t6065:collection || "/" || $t6065:source-doc-name) | ||
| } | ||
| (: ,"delivery-format": "serialized":) |
There was a problem hiding this comment.
oh right - leftovers from testing
Description:
Fixes several long-standing issues with imports and URI resolution in fn:transform
Reference:
fixes #5052
refs #6065
Type of tests:
XQSuite tests added