Skip to content

Commit 09a41b4

Browse files
committed
[test] document as parameter to fn:transform
Previously this resulted in org.exist.xquery.XPathException: java:java.lang.ClassCastException class org.exist.dom.persistent.NodeProxy cannot be cast to class org.w3c.dom.Node (org.exist.dom.persistent.NodeProxy is in unnamed module of loader 'app'; org.w3c.dom.Node is in module java.xml of loader 'bootstrap') Now it succeeds.
1 parent fddbfd3 commit 09a41b4

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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+
xquery version "3.1";
23+
24+
module namespace testTransform="http://exist-db.org/xquery/test/function_transform";
25+
import module namespace xmldb="http://exist-db.org/xquery/xmldb";
26+
declare namespace test="http://exist-db.org/xquery/xqsuite";
27+
28+
declare variable $testTransform:stylesheet := <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
29+
<xsl:param name='v'/>
30+
<xsl:template match='/'>
31+
<v><xsl:value-of select='$v'/></v>
32+
</xsl:template>
33+
</xsl:stylesheet>;
34+
35+
declare variable $testTransform:document := <document>
36+
<catalog>
37+
<book id="bk101">
38+
<author>Gambardella, Matthew</author>
39+
<title>XML Developer's Guide</title>
40+
<genre>Computer</genre>
41+
<price>44.95</price>
42+
<publish_date>2000-10-01</publish_date>
43+
<description>An in-depth look at creating applications
44+
with XML.</description>
45+
</book>
46+
<book id="bk102">
47+
<author>Ralls, Kim</author>
48+
<title>Midnight Rain</title>
49+
<genre>Fantasy</genre>
50+
<price>5.95</price>
51+
<publish_date>2000-12-16</publish_date>
52+
<description>A former architect battles corporate zombies,
53+
an evil sorceress, and her own childhood to become queen
54+
of the world.</description>
55+
</book>
56+
</catalog>
57+
</document>;
58+
59+
declare
60+
%test:setUp
61+
function testTransform:setup() {
62+
let $coll := xmldb:create-collection("/db", "regression-test")
63+
let $storeStylesheet := xmldb:store($coll, "stylesheet.xsl", $testTransform:stylesheet, "application/xslt+xml")
64+
return ( xmldb:store($coll, "document.xml", $testTransform:document, "application/document")
65+
)
66+
};
67+
68+
declare
69+
%test:tearDown
70+
function testTransform:cleanup() {
71+
xmldb:remove("/db/regression-test")
72+
};
73+
74+
declare
75+
%test:assertEquals("<v>Gambardella, MatthewXML Developer's GuideComputer44.952000-10-01An in-depth look at creating applications
76+
with XML.Ralls, KimMidnight RainFantasy5.952000-12-16A former architect battles corporate zombies,
77+
an evil sorceress, and her own childhood to become queen
78+
of the world.</v>")
79+
function testTransform:regression-test-1() {
80+
let $in := parse-xml("<dummy/>")
81+
let $result := ( fn:transform(map{
82+
"source-node":$in,
83+
"stylesheet-node":doc("/db/regression-test/stylesheet.xsl"),
84+
"stylesheet-params": map { QName("","v"): doc("/db/regression-test/document.xml") } } ) )?output
85+
return $result
86+
};
87+

0 commit comments

Comments
 (0)