Hi,
I didn't realize the ',' would take me that far out. I was reading it as 'join' type of punctuation.
This explains that. Everything works as expected now.
Thank you!
On Tue, Jul 17, 2012 at 3:03 AM, M. van Keulen m.vankeulen@utwente.nlwrote:
Hi,
Not that I tested or tried it, but it seems to me to be a matter operator priorities, hence of brackets around both db:replace functions: ( db:replace(...) , db:replace(...) ). Otherwise the XQuery parser will parse it as
updating function ... { ( let ... for ... let ... let ... return db:replace(...) ) , db:replace(...) }
Do you see how this makes your $target-skeleton-uri out-of-scope?
Regards, Maurice van Keulen
On 16-07-12 17:04, France Baril wrote:
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 Baril P.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