Revision [708]

This is an old revision of XPathExtension made by DavidLee on 2009-09-04 14:11:02.

 

XPath Extensions


With Version 0.1.0.0 an XPath extension is available in xmlsh which allows calling into xmlsh from with any xpath context including xpath, xlst, xquery, and the builtin &lt[ ... ]> commands.


To use this extension you need to use the saxon syntax for binding java extensions to saxon. (Note: this may change in the future, in particular if xmlsh is upgraded to use Saxon 9.2).

The java class to import is org.xmlsh.xpath.XPathFunctions
This can be done in the shell, or within an xslt or xquery script itself by using "declare namespace"
Example
declare namespace xmlsh=java:org.xmlsh.xpath.XPathFunctions


This namespace is predeclared for the XML expression syntax <[ ... ]>.
For example, the following works without using an explicit declaration
echo <[  <foo/>/xmlsh:eval("xcat") ]>


In order to use the extension functions within the xpath, xquery or xslt commands it must be declared either within xmlsh or for the case of xquery and xslt within their code/stylesheets.



Extension functions implemented


eval


The eval xpath function evaluates its first argument as an xmlsh string (identical to the eval command) and optionally its second argument as positional parameters. The return value of the eval function is the standard output of the command.

Examples
declare namespace xmlsh=java:org.xmlsh.xpath.XPathFunctions
xecho <[ xmlsh:eval("xecho $*" , ("foo" , <bar/> , 1 )  )  ]>
xquery -n 'xmlsh:eval("xls")'
xpath -n 'xmlsh:eval("xls $*" , "*.xml")'
var=<[ xmlsh:eval("xls") ]>



There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki