# Motivation

You want to use environment variables to change the way an XQuery executes.

XQuery 3.0 introduced two new functions:

``` available-environment-variables() as xs:string* - returns a sequence of strings of all the environment variables available
```
``` environment-variable(\$name as xs:string) as xs:string? - returns the value of a specific environment variable
```

# Sample Program

```xquery version "3.0";
<results>
{
for \$variable in available-environment-variables()
return
<var name="{\$variable}" value="{environment-variable(\$variable)}"/>
}
</results>
```

# Sample Results

Here are some sample results on a Windows 7 System:

```<var name="EXIST_HOME" value="d:\eXist\exist-2.0"/>
<var name="JAVA_HOME" value="D:\Apps\java\java6"/>
<var name="JAVA_OPTS" value=""-Xms128m -Xmx10024m -Dfile.encoding=UTF-8 -Djava.endorsed.dirs="d:\eXist\exist-2.0"\lib\endorsed""/>
<var name="JAVA_ENDORSED_DIRS" value=""d:\eXist\exist-2.0"\lib\endorsed"/>
<var name="JMX_PORT" value="1099"/>
<var name="JMX_OPTS" value=""-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false""/>

<var name="PROCESSOR_LEVEL" value="6"/>
<var name="PROCESSOR_REVISION" value="2a07"/>

<var name="COMPUTERNAME" value="DANS-NOT-A-MAC"/>
<var name="SystemRoot" value="C:\Windows"/>
<var name="USERPROFILE" value="C:\Users\Dan"/>
<var name="SystemDrive" value="C:"/>

<var name="Path" value="D:\apps\exist\exist-2.0\bin;
D:\apps\apache-ant-1.8.3\bin;D:\apps\git\bin;
D:\Apps\maven\bin;D:\apps\tomcat\bin;"/>

<var name="SESSIONNAME" value="Console"/>
<var name="MX" value="10024"/>
<var name="TMP" value="C:\Users\Dan\AppData\Local\Temp"/>

<var name="PROMPT" value="\$P\$G"/>
<var name="PATHEXT" value=".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC"/>
```

Note that Environment Variables are not the same as system-properties. System properties are key-value pairs typically set by Java. Environment Variables are typically key-value pairs associated with a shell.