|
| 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 |
| 36 | + %test:setUp |
| 37 | +function testTransform:setup() { |
| 38 | + let $coll := xmldb:create-collection("/db", "regression-test-1") |
| 39 | + return ( |
| 40 | + xmldb:store($coll, "stylesheet.xsl", $testTransform:stylesheet, "application/xslt+xml") |
| 41 | + ) |
| 42 | +}; |
| 43 | + |
| 44 | +declare |
| 45 | + %test:tearDown |
| 46 | +function testTransform:cleanup() { |
| 47 | + xmldb:remove("/db/regression-test-1") |
| 48 | +}; |
| 49 | + |
| 50 | +declare |
| 51 | + %test:assertEquals("<v>2</v>") |
| 52 | +function testTransform:regression-test-1() { |
| 53 | + let $in := parse-xml("<dummy/>") |
| 54 | + let $result := ( fn:transform(map{ |
| 55 | + "source-node":$in, |
| 56 | + "stylesheet-node":doc("/db/regression-test-1/stylesheet.xsl"), |
| 57 | + "stylesheet-params": map { QName("","v"): "2" } } ) )?output |
| 58 | + return $result |
| 59 | +}; |
| 60 | + |
0 commit comments