Ok... meanwhile I did some quick hacking and came up with the following 
solution.  The idea of storing properties is based on how the 
Cocoon-Spring-Configurator searches for properties in the classpath.

http://robbypelssers.blogspot.nl/2012/09/using-properties-from-within-xquery.html

Any improvements or comments are welcome.

Robby

-----Original Message-----
From: Robby Pelssers [mailto:robby.pelss...@nxp.com] 
Sent: Thursday, September 13, 2012 1:17 PM
To: sedna-discussion@lists.sourceforge.net
Subject: Re: [Sedna-discussion] question related to external global variables

Hi Charles,

Excellent suggestion.  It's not the usual approach we take to set properties 
but there's also nothing stopping me from storing XML in Sedna containing 
properties.

Brilliant workaround ;-)

Thx,
Robby

-----Original Message-----
From: charles.fos...@gmail.com [mailto:charles.fos...@gmail.com] On Behalf Of 
Charles Foster
Sent: Thursday, September 13, 2012 12:52 PM
To: Robby Pelssers
Cc: sedna-discussion@lists.sourceforge.net
Subject: Re: [Sedna-discussion] question related to external global variables

Hi Robby,

XQuery Library Modules (stored in Sedna) [1] can not have external variables.
Only XQuery Main Modules (i.e. Ad-hoc queries) can have external
variables, you can bind these from the XQJ driver.

You could set a constant variable in an XQuery Library Module.

e.g.

import module namespace constants = "http://http://prod.nxp.com/constants";;

declare function rdfutil:getURI($type as xs:string, $id as xs:string)
as xs:anyURI {
   xs:anyURI(concat($constants:base_uri, "/id/", $type, "/",
rdfutil:normalizeIdentifier($id)))
};

If you want flexibility, you could have an XQuery Library Module which
provided functions to read values (like a base-uri) from a XML
document existing in the Database.

If you want to import no library module AND want for the variable like
$base-uri to exist for every single ad-hoc XQuery you invoke, you will
need to declare an external variable and bind via XQExpression or
XQPreparedExpression.

Hope this helps.

Regards,

Charles

[1] http://www.sedna.org/progguide/ProgGuidesu8.html#x14-570002.5.5


On 13 September 2012 11:15, Robby Pelssers <robby.pelss...@nxp.com> wrote:
> Hi all,
>
> I've read that Sedna does not support external variables 
> http://www.sedna.org/progguide/ProgGuidesu4.html
>
> But I have a function that needs to return a URI which is environment 
> specific.
>
> declare function rdfutil:getURI($type as xs:string, $id as xs:string) as 
> xs:anyURI {
>    xs:anyURI(concat("http://prod.nxp.com";, "/id/", $type, "/", 
> rdfutil:normalizeIdentifier($id)))
> };
>
> So ideally I want to use a global variable which I can set externally.  (e.g. 
> $base_uri)
>
> declare function rdfutil:getURI($type as xs:string, $id as xs:string) as 
> xs:anyURI {
>    xs:anyURI(concat($base_uri, "/id/", $type, "/", 
> rdfutil:normalizeIdentifier($id)))
> };
>
> But Sedna won't allow me to deploy this module which is understandable as I 
> reference a non declared variable
>
> Details: at (10:35), syntax error, unexpected ;, expecting := or as or 
> external
>
>
> I could of course change the function signature to
> declare function rdfutil:getURI($base_uri as xs:string, $type as xs:string, 
> $id as xs:string) as xs:anyURI {
>    xs:anyURI(concat($base_uri, "/id/", $type, "/", 
> rdfutil:normalizeIdentifier($id)))
> };
>
> But this would have to get propagated to ALL functions calling 
> rdfutil:getURI, which more concretely would involve changing every single 
> function as they all depend on this rdfutil:getURI (in)directly.
>
> As a side note,
>
> We are using the driver from Charles Foster but that won't help us in this 
> case as this use case is about modules and not standalone xqueries used in 
> our app.
>
> So besides the tedious solution of refactoring all function signatures, is 
> there a simpler way?
>
> Thx in advance,
> Robby
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Sedna-discussion mailing list
> Sedna-discussion@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sedna-discussion
>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Sedna-discussion mailing list
Sedna-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sedna-discussion

------------------------------------------------------------------------------
Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.
http://ad.doubleclick.net/clk;262219671;13503038;y?
http://info.appdynamics.com/FreeJavaPerformanceDownload.html
_______________________________________________
Sedna-discussion mailing list
Sedna-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sedna-discussion

Reply via email to