updating function ... {Do you see how this makes your $target-skeleton-uri out-of-scope?
( let ... for ... let ... let ... return db:replace(...) ) , db:replace(...)
}
Hi,
I have a process where for each input file, I must create 2 output files. For some reason, I seem to be unable to use more than 1 db:replace in the same function. I have tried pieces of code separately to ensure that every individual piece works. They do work. For your information, I have included my tests as comments after the function.
(: param $lang is the desired target language of the translation :)
declare %rest:path("/admin/convert-to-xliff")
%rest:GET
%rest:query-param("lang", "{$lang}", '')
updating function admin:convert-to-xliff($lang as xs:string){
(: Src language is assumed to always be en-us as per business rules:)
let $src-lang := "en-us"
for $x in app:open-db($src-lang)
let $xliff-stylesheet := app:get-translation-xliff-to-xsl()
let $skeleton-stylesheet := app:get-translation-xliff-skeleton-xsl()
let $params := map {"lang-to" := $lang}
let $target-uri := replace(base-uri($x), $src-lang, $lang)
let $target-skeleton-uri := replace($target-uri, '.xml', '_xliffskeleton.xml')
let $xliff-doc := xslt:transform($x, $xliff-stylesheet, $params)
let $xliff-skeleton := xslt:transform($x, $skeleton-stylesheet)
return db:replace("Translated-units", $target-uri, document{$xliff-doc}), db:replace("Translated-units", $target-skeleton-uri, document {$xliff-skeleton})
};
(: db:replace("Translated-units", $target-uri, document{$xliff-doc}) --- Creates the expected files in the expected location :)
(: db:replace("Translated-units", $target-skeleton-uri, document {$xliff-skeleton}) --- Creates the expected files in the expected location :)
(: concat($target-uri, ' --- ', $target-skeleton-uri) --- remove decl as updating function to test this, both paths are set :)
- I tested the $target-uri and $target-skeleton-uri as strings, and they both get the expected values as string outputs.
- The db:replace for each of them works individually.
- However, when I try 2 db:replace, the second one return an error: [XPST0008] Undefined variable $target-skeleton-uri.
- If I reverse the db:replace, the 'new' second one gets the error: [XPST0008] Undefined variable $target-uri. Therefore, it looks like it has nothing to do with the fact that the variable is undefined.
Any clue?
Thanks,
France BarilP.S. I'm using BaseX 7.2.1--
France Baril
Architecte documentaire / Documentation architect
france.baril@architextus.com
(514) 572-0341
-- ---------------------------------------------------------------------- Dr.Ir. M. van Keulen - Associate Professor, Data Management Technology Univ. of Twente, Dept of EEMCS, POBox 217, 7500 AE Enschede, Netherlands Email: m.vankeulen@utwente.nl, Phone: +31 534893688, Fax: +31 534892927 Room: ZI 3039, WWW: http://www.cs.utwente.nl/~keulen