Tree navigation

With XSH, it is possible to browse document trees as if they were a local filesystem, except that XPath expressions are used instead of ordinary UNIX paths.

Current position in the document tree is called the current node. Current node's XPath may be queried with pwd command. In the interactive shell, current node is also displayed in the command line prompt. Remember, that beside cd command, current node (and document) is silently changed by all variant of open command, create command and temporarily also by the node-list variant of the foreach statement.

Documents are specified in a similar way as harddrives on DOS/Windows(TM) systems (except that their names are not limitted to one letter in XSH), i.e. by a prefix of the form doc: where doc is the id associated with the document.

To mimic the filesystem navigation as closely as possible, XSH contains several commands named by analogy of UNIX filesystem commands, such as cd, ls and pwd.

xsh scratch:/> open docA="testA.xml"
xsh docB:/> open docB="testB.xml"
xsh> pwd
docB:/
xsh docB:/> cd docA:/article/chapter[title='Conclusion']
xsh docA:/article/chapter[5]> pwd
docA:/article/chapter[5]
xsh docA:/article/chapter[5]> cd previous-sibling::chapter
xsh docA:/article/chapter[4]> cd ..
xsh docA:/article> select docB
xsh docB:/>

Related Argument Types and Commands

cd

change current context node

fold

mark elements to be folded by list command

locate

show a given node location (as a cannonical XPath)

ls

list a given part of a document as XML

pwd

show current context node location (as a cannonical XPath)

register-function

define XPath extension function (EXPERIMENTAL)

register-namespace

register namespace prefix to use XPath expressions

register-xhtml-namespace

register XHTML namespace prefix to use XPath expressions

register-xsh-namespace

register XSH namespace prefix to use XPath expressions

select

make a given document the current one

unfold

unfold elements folded with fold command

unregister-function

undefine extension function (EXPERIMENTAL)

unregister-namespace

unregister namespace prefix

xpath

XPath expression