When I run my xsl stylesheet, I need to know if some files are present. Because xslt has no native way to test if a file exists (ASFAIK), I want to do this with javascript. Usually I'm working with the saxon 9 HE, but some colleagues told me that javascript functions were not supported with the HE edition. Is there a way to execute java script functions with saxon 9 HE?
I've tried this example: How to include javaScript file in xslt , but oxygen gave me this error: "Cannot find a matching 1-argument function named".
You can use the XPath functions doc-available
https://www.w3.org/TR/xpath-functions/#func-doc-available and unparsed-text-available
https://www.w3.org/TR/xpath-functions/#func-unparsed-text-available to check whether an XML document or an non-XML text document is present.
There is no support for using Javascript with Saxon 9 (and a simple ECMAScript/Javascript engine usually does not include any file IO functionality anyway) but there is a feature called integrated extension functions http://saxonica.com/html/documentation/extensibility/integratedfunctions/ you can use in Saxon 9 (all editions) to call Java code. In Saxon 9 PE and EE you can additionally use reflexive extension functions to call Java code directly from the XSLT code.