Skip to content

Commit 3f41d99

Browse files
committed
[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.
1 parent b09da11 commit 3f41d99

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

exist-core/src/main/java/org/exist/xquery/functions/fn/transform/Options.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,8 @@ public Optional<T> get(final MapType options) throws XPathException {
420420
if (item0 != null) {
421421
if (Type.subTypeOf(item0.getType(), itemSubtype)) {
422422
return Optional.of((T) item0);
423+
} else if (itemSubtype == Type.STRING && Type.subTypeOf(item0.getType(), Type.ATOMIC)) {
424+
return Optional.of((T)new StringValue(item0.getStringValue()));
423425
} else {
424426
throw new XPathException(
425427
ErrorCodes.XPTY0004, "Type error: expected " + Type.getTypeName(itemSubtype) + ", got " + Type.getTypeName(item0.getType()));

exist-core/src/main/java/org/exist/xquery/value/Type.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ public class Type {
201201

202202
// STRING sub-types
203203
defineSubType(STRING, NORMALIZED_STRING);
204-
defineSubType(STRING, ANY_URI); // we can always treat a URI as a string
205204

206205
// NORMALIZED_STRING sub-types
207206
defineSubType(NORMALIZED_STRING, TOKEN);
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
(:
2+
: eXist-db Open Source Native XML Database
3+
: Copyright (C) 2001 The eXist-db Authors
4+
:
5+
6+
: http://www.exist-db.org
7+
:
8+
: This library is free software; you can redistribute it and/or
9+
: modify it under the terms of the GNU Lesser General Public
10+
: License as published by the Free Software Foundation; either
11+
: version 2.1 of the License, or (at your option) any later version.
12+
:
13+
: This library is distributed in the hope that it will be useful,
14+
: but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
: Lesser General Public License for more details.
17+
:
18+
: You should have received a copy of the GNU Lesser General Public
19+
: License along with this library; if not, write to the Free Software
20+
: Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
:)
22+
23+
xquery version "3.1";
24+
25+
module namespace testTransform="http://exist-db.org/xquery/test/function_transform";
26+
27+
declare namespace test="http://exist-db.org/xquery/xqsuite";
28+
29+
declare variable $testTransform:transform-33-xsl := "<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='3.0'>
30+
<xsl:template match='/'> <xsl:for-each select='//section'>
31+
<xsl:result-document href='section{position()}.html'> <!-- instructions content here -->
32+
</xsl:result-document> </xsl:for-each>
33+
</xsl:template> </xsl:stylesheet>";
34+
35+
declare variable $testTransform:transform-33-xml := "<doc>
36+
<section>sect1</section>
37+
<section>sect2</section>
38+
<section>sect3</section>
39+
</doc>";
40+
41+
declare
42+
%test:assertTrue
43+
function testTransform:transform-33() {
44+
let $xsl := $testTransform:transform-33-xsl
45+
let $xml := $testTransform:transform-33-xml
46+
let $result := fn:transform(map {"stylesheet-text": $xsl, "source-node": parse-xml($xml),
47+
"base-output-uri" : resolve-uri("transform/sandbox/fn-transform-33.xml", "http://www.w3.org/fots/fn/transform/staticbaseuri.xsl"),
48+
"delivery-format":"serialized"})
49+
return (contains(string-join(map:keys($result)),"section2"))
50+
};

0 commit comments

Comments
 (0)