-
-
Notifications
You must be signed in to change notification settings - Fork 192
[bugfix] Forward port PR #6544: fix XSLT imports and document builder isolation #6546
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0635f59
[bugfix] Forward port PR #6544: fix XSLT imports and document builder…
line-o 9ff0e6e
Fix: Don't over-resolve database URIs in stylesheet base URI handling
line-o 9312dc4
Fix: Handle null document URI in stylesheet location resolution
line-o b791e72
[bugfix] Fix XSLT stylesheet resolution for relative xsl:include/xsl:…
line-o 0b9170f
[refactor] Use instanceof pattern matching in stylesheet location res…
line-o f200c0e
[bugfix] Do not double the xmldb: prefix when resolving against an xm…
line-o 0ddf7a6
[bugfix] Treat an extensionless base as a collection when resolving a…
line-o File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
199 changes: 199 additions & 0 deletions
199
exist-core/src/test/xquery/xquery3/transform/fnTransform5052.xqm
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,199 @@ | ||
| (: | ||
| : eXist-db Open Source Native XML Database | ||
| : Copyright (C) 2001 The eXist-db Authors | ||
| : | ||
| : info@exist-db.org | ||
| : http://www.exist-db.org | ||
| : | ||
| : This library is free software; you can redistribute it and/or | ||
| : modify it under the terms of the GNU Lesser General Public | ||
| : License as published by the Free Software Foundation; either | ||
| : version 2.1 of the License, or (at your option) any later version. | ||
| : | ||
| : This library is distributed in the hope that it will be useful, | ||
| : but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| : Lesser General Public License for more details. | ||
| : | ||
| : You should have received a copy of the GNU Lesser General Public | ||
| : License along with this library; if not, write to the Free Software | ||
| : Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| :) | ||
| xquery version "3.1"; | ||
|
|
||
| (:~ | ||
| : Tests for issue 5052: fn:transform does not resolve relative URIs | ||
| : against the database. | ||
| : | ||
| : Covers: | ||
| : - relative xsl:include / xsl:import hrefs in stylesheets stored in the | ||
| : database (resolved from the containing collection of the stylesheet) | ||
| : - a relative "stylesheet-location" in a query stored in the database | ||
| : (resolved from the containing collection of the query, consistent | ||
| : with fn:doc and transform:transform) | ||
| : | ||
| : @see https://github.com/eXist-db/exist/issues/5052 | ||
| :) | ||
| module namespace t5052="http://exist-db.org/xquery/test/fn-transform-5052"; | ||
|
|
||
| import module namespace xmldb="http://exist-db.org/xquery/xmldb"; | ||
| import module namespace util="http://exist-db.org/xquery/util"; | ||
|
|
||
| declare namespace test="http://exist-db.org/xquery/xqsuite"; | ||
| declare namespace xsl="http://www.w3.org/1999/XSL/Transform"; | ||
|
|
||
| declare variable $t5052:coll-name := "fn-transform-5052"; | ||
| declare variable $t5052:coll := "/db/" || $t5052:coll-name; | ||
|
|
||
| declare variable $t5052:plain-xsl := | ||
| <xsl:stylesheet version="3.0"> | ||
| <xsl:template match="/"><plain-ok/></xsl:template> | ||
| </xsl:stylesheet>; | ||
|
|
||
| declare variable $t5052:included-xsl := | ||
| <xsl:stylesheet version="3.0"> | ||
| <xsl:template name="hello"><hello>included</hello></xsl:template> | ||
| </xsl:stylesheet>; | ||
|
|
||
| declare variable $t5052:main-include-xsl := | ||
| <xsl:stylesheet version="3.0"> | ||
| <xsl:include href="included.xsl"/> | ||
| <xsl:template match="/"><result><xsl:call-template name="hello"/></result></xsl:template> | ||
| </xsl:stylesheet>; | ||
|
|
||
| declare variable $t5052:imported-xsl := | ||
| <xsl:stylesheet version="3.0"> | ||
| <xsl:template name="greet"><greet>imported</greet></xsl:template> | ||
| </xsl:stylesheet>; | ||
|
|
||
| declare variable $t5052:main-import-xsl := | ||
| <xsl:stylesheet version="3.0"> | ||
| <xsl:import href="sub/imported.xsl"/> | ||
| <xsl:template match="/"><result><xsl:call-template name="greet"/></result></xsl:template> | ||
| </xsl:stylesheet>; | ||
|
|
||
| declare variable $t5052:nested-a-xsl := | ||
| <xsl:stylesheet version="3.0"> | ||
| <xsl:include href="nested-b.xsl"/> | ||
| </xsl:stylesheet>; | ||
|
|
||
| declare variable $t5052:nested-b-xsl := | ||
| <xsl:stylesheet version="3.0"> | ||
| <xsl:template name="deep"><deep>nested</deep></xsl:template> | ||
| </xsl:stylesheet>; | ||
|
|
||
| declare variable $t5052:main-nested-xsl := | ||
| <xsl:stylesheet version="3.0"> | ||
| <xsl:include href="sub/nested-a.xsl"/> | ||
| <xsl:template match="/"><result><xsl:call-template name="deep"/></result></xsl:template> | ||
| </xsl:stylesheet>; | ||
|
|
||
| (: a query stored in the database, using a stylesheet-location relative to its collection :) | ||
| declare variable $t5052:relative-location-xq := | ||
| 'xquery version "3.1"; | ||
| fn:transform(map{ | ||
| "stylesheet-location": "plain.xsl", | ||
| "source-node": document { <input/> } | ||
| })?output'; | ||
|
|
||
| (: as above, but with a base-uri declared in the prolog: the collection URI without a | ||
| : trailing slash, as reported in https://github.com/eXist-db/exist/issues/5052 :) | ||
| declare variable $t5052:relative-location-base-uri-xq := | ||
| 'xquery version "3.1"; | ||
| declare base-uri "/db/fn-transform-5052"; | ||
| fn:transform(map{ | ||
| "stylesheet-location": "plain.xsl", | ||
| "source-node": document { <input/> } | ||
| })?output'; | ||
|
|
||
| declare | ||
| %test:setUp | ||
| function t5052:setup() { | ||
| xmldb:create-collection("/db", $t5052:coll-name), | ||
| xmldb:create-collection($t5052:coll, "sub"), | ||
| xmldb:store($t5052:coll, "plain.xsl", $t5052:plain-xsl), | ||
| xmldb:store($t5052:coll, "included.xsl", $t5052:included-xsl), | ||
| xmldb:store($t5052:coll, "main-include.xsl", $t5052:main-include-xsl), | ||
| xmldb:store($t5052:coll || "/sub", "imported.xsl", $t5052:imported-xsl), | ||
| xmldb:store($t5052:coll, "main-import.xsl", $t5052:main-import-xsl), | ||
| xmldb:store($t5052:coll || "/sub", "nested-a.xsl", $t5052:nested-a-xsl), | ||
| xmldb:store($t5052:coll || "/sub", "nested-b.xsl", $t5052:nested-b-xsl), | ||
| xmldb:store($t5052:coll, "main-nested.xsl", $t5052:main-nested-xsl), | ||
| xmldb:store($t5052:coll, "relative-location.xq", $t5052:relative-location-xq, "application/xquery"), | ||
| xmldb:store($t5052:coll, "relative-location-base-uri.xq", $t5052:relative-location-base-uri-xq, "application/xquery") | ||
| }; | ||
|
|
||
| declare | ||
| %test:tearDown | ||
| function t5052:tearDown() { | ||
| xmldb:remove($t5052:coll) | ||
| }; | ||
|
|
||
| (:~ Control: absolute stylesheet-location without includes works before and after the fix. :) | ||
| declare | ||
| %test:assertEquals("<plain-ok/>") | ||
| function t5052:absolute-location-no-include() { | ||
| fn:transform(map{ | ||
| "stylesheet-location": $t5052:coll || "/plain.xsl", | ||
| "source-node": document { <input/> } | ||
| })?output | ||
| }; | ||
|
|
||
| (:~ Relative xsl:include, resolved from the collection containing the stylesheet. :) | ||
| declare | ||
| %test:assertEquals("<result><hello>included</hello></result>") | ||
| function t5052:include-relative-same-collection() { | ||
| fn:serialize(fn:transform(map{ | ||
| "stylesheet-location": $t5052:coll || "/main-include.xsl", | ||
| "source-node": document { <input/> } | ||
| })?output) | ||
| }; | ||
|
|
||
| (:~ Relative xsl:import into a sub-collection. :) | ||
| declare | ||
| %test:assertEquals("<result><greet>imported</greet></result>") | ||
| function t5052:import-relative-sub-collection() { | ||
| fn:serialize(fn:transform(map{ | ||
| "stylesheet-location": $t5052:coll || "/main-import.xsl", | ||
| "source-node": document { <input/> } | ||
| })?output) | ||
| }; | ||
|
|
||
| (:~ Base URI must be propagated per stylesheet module: sub/nested-a.xsl includes | ||
| : nested-b.xsl which lives next to it in sub/. :) | ||
| declare | ||
| %test:assertEquals("<result><deep>nested</deep></result>") | ||
| function t5052:include-relative-nested() { | ||
| fn:serialize(fn:transform(map{ | ||
| "stylesheet-location": $t5052:coll || "/main-nested.xsl", | ||
| "source-node": document { <input/> } | ||
| })?output) | ||
| }; | ||
|
|
||
| (:~ Relative xsl:include where the stylesheet is passed as a persistent | ||
| : stylesheet-node stored in the database. :) | ||
| declare | ||
| %test:assertEquals("<result><hello>included</hello></result>") | ||
| function t5052:stylesheet-node-stored-include() { | ||
| fn:serialize(fn:transform(map{ | ||
| "stylesheet-node": doc($t5052:coll || "/main-include.xsl"), | ||
| "source-node": document { <input/> } | ||
| })?output) | ||
| }; | ||
|
|
||
| (:~ A query stored in the database resolves a relative stylesheet-location | ||
| : from its own collection (as fn:doc and transform:transform do). :) | ||
| declare | ||
| %test:assertEquals("<plain-ok/>") | ||
| function t5052:relative-location-stored-query() { | ||
| fn:serialize(util:eval(xs:anyURI($t5052:coll || "/relative-location.xq"))) | ||
| }; | ||
|
|
||
| (:~ As reported in issue 5052: a declared base-uri pointing to a collection | ||
| : (no trailing slash) must not lose its last path segment when a relative | ||
| : stylesheet-location is resolved against it. :) | ||
| declare | ||
| %test:assertEquals("<plain-ok/>") | ||
| function t5052:relative-location-collection-base-uri() { | ||
| fn:serialize(util:eval(xs:anyURI($t5052:coll || "/relative-location-base-uri.xq"))) | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.