When invoking xquery, xpath or xslt or using the internal XML expression syntax (<[ ...]> ) you can call *out* to xmlsh using an XPath extension function.
This allows you do run any xmlsh code from within XQuery, XPath or xslt as part of an XPath expression. The context is passed as the input to the xmlsh code and the output of the xmlsh code is the return value of the expression.
For example you can call xslt from within xquery using this syntax
/foo/bar/xmlsh:eval("xlst -f stylesheet.xsl")/spam
See XPath extension function for details.