# fn:path - XPath XQuery Reference

Returns a path expression that can be used to select the supplied node relative to the
            root of its containing document.deterministiccontext-dependentfocus-dependentdeterministiccontext-independentfocus-independentThe behavior of the function if the argument is omitted is exactly the same as if the
            context item (.) had been passed as the argument.If $arg is the empty sequence, the function returns the empty sequence.If $arg is a document node, the function returns the string
               "/".Otherwise, the function returns a string that consists of a sequence of steps, one
            for each ancestor-or-self of $arg other than the root node. This string is
            prefixed by "Q{http://www.w3.org/2005/xpath-functions}root()" if the root
            node is not a document node. Each step consists of the character "/"
            followed by a string whose form depends on the kind of node selected by that step, as
            follows:For an element node,
                        Q{uri}local[position],
                  where uri is the namespace URI of the node name or the
                  empty string if the node is in no namespace, local is
                  the local part of the node name, and position is an
                  integer representing the position of the selected node among its like-named
                  siblings.For an attribute node:if the node is in no namespace, @local, where
                              local is the local part of the node nameotherwise, @Q{uri}local, where
                              uri is the namespace URI of the node name,
                        and local is the local part of the node nameFor a text node: text()[position] where
                        position is an integer representing the position
                  of the selected node among its text node siblingsFor a comment node: comment()[position] where
                        position is an integer representing the position
                  of the selected node among its comment node siblingsFor a processing-instruction node:
                        processing-instruction(local)[position]
                  where local is the name of the processing instruction
                  node and position is an integer representing the
                  position of the selected node among its like-named processing-instruction node
                  siblingsFor a namespace node:If the namespace node has a name:
                           namespace::prefix, where
                              prefix is the local part of the name of the
                        namespace node (which represents the namespace prefix).If the namespace node has no name (that is, it represents the default
                        namespace):
                           namespace::*[Q{http://www.w3.org/2005/xpath-functions}local-name()=""]
document {            
<p xmlns="http://example.com/one" xml:lang="de" author="Friedrich von Schiller">
Freude, schöner Götterfunken,<br/>
Tochter aus Elysium,<br/>
Wir betreten feuertrunken,<br/>
Himmlische, dein Heiligtum.</p>}fn:path($e)'/'fn:path($e/*:p)'/Q{http://example.com/one}p[1]'fn:path($e/*:p/@xml:lang)'/Q{http://example.com/one}p[1]/@Q{http://www.w3.org/XML/1998/namespace}lang'fn:path($e/*:p/@author)'/Q{http://example.com/one}p[1]/@author'fn:path($e/*:p/*:br[2])'/Q{http://example.com/one}p[1]/Q{http://example.com/one}br[2]'fn:path($e//text()[starts-with(normalize-space(),
                  'Tochter')])'/Q{http://example.com/one}p[1]/text()[2]'
            <employee xml:id="ID21256">
               <empnr>E21256</empnr>
               <first>John</first>
               <last>Brown</last>
            </employee>fn:path($emp)'Q{http://www.w3.org/2005/xpath-functions}root()'fn:path($emp/@xml:id)'Q{http://www.w3.org/2005/xpath-functions}root()/@Q{http://www.w3.org/XML/1998/namespace}id'fn:path($emp/empnr)'Q{http://www.w3.org/2005/xpath-functions}root()/Q{}empnr[1]'The following errors may be raised when $arg is omitted:If the context item is absent,
                  dynamic error If the context item is not a node, type error .