IC5Notice: We have upgraded developerWorks Community to the latest version of IBM Connections. For more information, read our upgrade FAQ.
Topic
  • 5 replies
  • Latest Post - ‏2013-01-24T16:35:47Z by SystemAdmin
SystemAdmin
SystemAdmin
6772 Posts

Pinned topic Are var://system variables scoped by domain?

‏2013-01-23T16:07:19Z |
I have read the doc on system variables and it isn't clear to me if they are scoped by domain or not.
var://system/variable
    Addresses a global variable that is available in all contexts. System variables persist beyond the scope 
    of request-response processing and can be read by other objects on the appliance. If the content of a 
    variable needs to be read or set outside the scope of request-response processing, use a system variable.

The words "other objects on the appliance" imply it is visible across all domains, although all other variable types described in the section are scoped to a domain.

So in other words, if I want a system variable to be domain specific, do I need to name it var://system/mydomain/variable or is var://system/variable good enough?
Updated on 2014-03-25T02:41:30Z at 2014-03-25T02:41:30Z by iron-man
  • swlinn
    swlinn
    1346 Posts

    Re: Are var://system variables scoped by domain?

    ‏2013-01-23T19:11:23Z  
    System variable are visible across all domains and across all requests. They are not thread safe, and thus care should be taken in their use. If you want a system variable that is specific to a domain, then var://system/mydomain-myvariable would work, but be careful as that variable is still visible to other domains. You'll need to create your services and xslt code to always use the domain name in the construction of the variable name to use.

    Regards,
    Steve
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: Are var://system variables scoped by domain?

    ‏2013-01-24T14:26:18Z  
    • swlinn
    • ‏2013-01-23T19:11:23Z
    System variable are visible across all domains and across all requests. They are not thread safe, and thus care should be taken in their use. If you want a system variable that is specific to a domain, then var://system/mydomain-myvariable would work, but be careful as that variable is still visible to other domains. You'll need to create your services and xslt code to always use the domain name in the construction of the variable name to use.

    Regards,
    Steve
    That's unfortunate, because I can't hardcode the name in my XSL if I want to use it in multiple domains and I cannot figure out how to get variable substitution to work in the dp:set-variable name.

    I can't get the whole name or even a partial part of the variable name to work.

    
    <xsl:variable name=
    "var1" value=
    "'var://system/soa/test'" /> <dp:set-variable name=
    "$var1" value=
    "1" /> <xsl:message dp:priority=
    "error">
    /// 1: <xsl:value-of select="dp:variable('var://system/soa/test')" /></xsl:message> <xsl:message dp:priority=
    "error">
    /// 2: <xsl:value-of select="dp:variable($var1)" /></xsl:message> <xsl:message dp:priority=
    "error">
    /// 3: <xsl:value-of select="dp:variable('{$var1}')" /></xsl:message> <dp:set-variable name=
    "'{$var1}'" value=
    "1" /> <xsl:message dp:priority=
    "error">
    /// 4: <xsl:value-of select="dp:variable('var://system/soa/test')" /></xsl:message> <xsl:message dp:priority=
    "error">
    /// 5: <xsl:value-of select="dp:variable($var1)" /></xsl:message> <xsl:message dp:priority=
    "error">
    /// 6: <xsl:value-of select="dp:variable('{$var1}')" /></xsl:message> <dp:set-variable name=
    "'var://system/soa/test'" value=
    "1" /> <xsl:message dp:priority=
    "error">
    /// 7: <xsl:value-of select="dp:variable('var://system/soa/test')" /></xsl:message> <xsl:message dp:priority=
    "error">
    /// 8: <xsl:value-of select="dp:variable($var1)" /></xsl:message> <xsl:message dp:priority=
    "error">
    /// 9: <xsl:value-of select="dp:variable('{$var1}')" /></xsl:message>
    


    All values are empty except for 7, so only the last set-variable with the hardcoded name worked. And only the hardcoded name in dp:variable() retrieved the value.
  • kenhygh
    kenhygh
    1480 Posts

    Re: Are var://system variables scoped by domain?

    ‏2013-01-24T15:45:22Z  
    That's unfortunate, because I can't hardcode the name in my XSL if I want to use it in multiple domains and I cannot figure out how to get variable substitution to work in the dp:set-variable name.

    I can't get the whole name or even a partial part of the variable name to work.

    <pre class="jive-pre"> <xsl:variable name= "var1" value= "'var://system/soa/test'" /> <dp:set-variable name= "$var1" value= "1" /> <xsl:message dp:priority= "error"> /// 1: <xsl:value-of select="dp:variable('var://system/soa/test')" /></xsl:message> <xsl:message dp:priority= "error"> /// 2: <xsl:value-of select="dp:variable($var1)" /></xsl:message> <xsl:message dp:priority= "error"> /// 3: <xsl:value-of select="dp:variable('{$var1}')" /></xsl:message> <dp:set-variable name= "'{$var1}'" value= "1" /> <xsl:message dp:priority= "error"> /// 4: <xsl:value-of select="dp:variable('var://system/soa/test')" /></xsl:message> <xsl:message dp:priority= "error"> /// 5: <xsl:value-of select="dp:variable($var1)" /></xsl:message> <xsl:message dp:priority= "error"> /// 6: <xsl:value-of select="dp:variable('{$var1}')" /></xsl:message> <dp:set-variable name= "'var://system/soa/test'" value= "1" /> <xsl:message dp:priority= "error"> /// 7: <xsl:value-of select="dp:variable('var://system/soa/test')" /></xsl:message> <xsl:message dp:priority= "error"> /// 8: <xsl:value-of select="dp:variable($var1)" /></xsl:message> <xsl:message dp:priority= "error"> /// 9: <xsl:value-of select="dp:variable('{$var1}')" /></xsl:message> </pre>

    All values are empty except for 7, so only the last set-variable with the hardcoded name worked. And only the hardcoded name in dp:variable() retrieved the value.
    this drove me batty for a while, until I finally looked at ALL the log, which had a compilation warning about the attribute 'value' for <xsl:variable>. d'oh!

    Take a look at this snippet, it gets values for 2,5, and 8. (3,6, and 9 have the wrong syntax).

    Ken

    <xsl:variable name="var1" select="'var://system/soa/test'" />
    <dp:set-variable name="$var1" value="'1'" />
    <xsl:message dp:priority="error">/// 1: <xsl:value-of select="dp:variable('var://system/soa/test')" /></xsl:message>
    <xsl:message dp:priority="error">/// 2: <xsl:value-of select="dp:variable($var1)" /></xsl:message>
    <xsl:message dp:priority="error">/// 3: <xsl:value-of select="dp:variable('{$var1}')" /></xsl:message>
    <dp:set-variable name="$var1" value="'2'" />
    <xsl:message dp:priority="error">/// 4: <xsl:value-of select="dp:variable('var://system/soa/test')" /></xsl:message>
    <xsl:message dp:priority="error">/// 5: <xsl:value-of select="dp:variable($var1)" /></xsl:message>
    <xsl:message dp:priority="error">/// 6: <xsl:value-of select="dp:variable('{$var1}')" /></xsl:message>
    <dp:set-variable name="'var://system/soa/test'" value="'3'" />
    <xsl:message dp:priority="error">/// 7: <xsl:value-of select="dp:variable('var://system/soa/test')" /></xsl:message>
    <xsl:message dp:priority="error">/// 8: <xsl:value-of select="dp:variable($var1)" /></xsl:message>
    <xsl:message dp:priority="error">/// 9: <xsl:value-of select="dp:variable('{$var1}')" /></xsl:message>
  • kenhygh
    kenhygh
    1480 Posts

    Re: Are var://system variables scoped by domain?

    ‏2013-01-24T15:47:26Z  
    • kenhygh
    • ‏2013-01-24T15:45:22Z
    this drove me batty for a while, until I finally looked at ALL the log, which had a compilation warning about the attribute 'value' for <xsl:variable>. d'oh!

    Take a look at this snippet, it gets values for 2,5, and 8. (3,6, and 9 have the wrong syntax).

    Ken

    <xsl:variable name="var1" select="'var://system/soa/test'" />
    <dp:set-variable name="$var1" value="'1'" />
    <xsl:message dp:priority="error">/// 1: <xsl:value-of select="dp:variable('var://system/soa/test')" /></xsl:message>
    <xsl:message dp:priority="error">/// 2: <xsl:value-of select="dp:variable($var1)" /></xsl:message>
    <xsl:message dp:priority="error">/// 3: <xsl:value-of select="dp:variable('{$var1}')" /></xsl:message>
    <dp:set-variable name="$var1" value="'2'" />
    <xsl:message dp:priority="error">/// 4: <xsl:value-of select="dp:variable('var://system/soa/test')" /></xsl:message>
    <xsl:message dp:priority="error">/// 5: <xsl:value-of select="dp:variable($var1)" /></xsl:message>
    <xsl:message dp:priority="error">/// 6: <xsl:value-of select="dp:variable('{$var1}')" /></xsl:message>
    <dp:set-variable name="'var://system/soa/test'" value="'3'" />
    <xsl:message dp:priority="error">/// 7: <xsl:value-of select="dp:variable('var://system/soa/test')" /></xsl:message>
    <xsl:message dp:priority="error">/// 8: <xsl:value-of select="dp:variable($var1)" /></xsl:message>
    <xsl:message dp:priority="error">/// 9: <xsl:value-of select="dp:variable('{$var1}')" /></xsl:message>
    BTW, I've made this same boo-boo countless times. <xsl:variable and <dp:set-variable, one would think should have identical signatures, but....

    Ken
  • SystemAdmin
    SystemAdmin
    6772 Posts

    Re: Are var://system variables scoped by domain?

    ‏2013-01-24T16:35:47Z  
    • kenhygh
    • ‏2013-01-24T15:47:26Z
    BTW, I've made this same boo-boo countless times. <xsl:variable and <dp:set-variable, one would think should have identical signatures, but....

    Ken
    Thanks for finding my mistake. The real issue was I wanted this variable name to come in as a stylesheet parameter and I couldn't get that to work, so I tried that test file with a hardcoded <xsl:variable> with the wrong syntax.

    But your success got me hopeful I could get the real problem licked. The problem with passing in a full variable name (e.g., var://system/soa/test) as a parameter value is that DataPower tries to evaluate it, which is what my original problem was.

    Instead, if I pass a partial name (e.g. soa/test) in as a parameter value, I can do the following which works!
    
    <xsl:param name=
    "dpconfig:testParam" select=
    "''"/> <dp:param name=
    "dpconfig:testParam" type=
    "dmString" required=
    "false" xmlns=
    ""> <display>testParam</display> <default></default> </dp:param> <xsl:template match=
    "/"> <xsl:variable name=
    "varName" select=
    "concat('var://system/',$dpconfig:testParam)" /> <dp:set-variable name=
    "$varName" value=
    "1" /> <xsl:message dp:priority=
    "error">
    /// var=<xsl:value-of select="$varName" />, value=<xsl:value-of select="dp:variable($varName)" /></xsl:message> </xsl:template>
    


    Maybe there's a cleaner incantation, but I'm happy!