I need to deal with legacy code which evaluates XPath expressions expects the results to resolve to NodeList. The code uses NodeList to identify how many nodes are selected by the XPath expression. The code proceeds only if one node is selected.
Now I need to use string-join function which return type is String. Is there any way to convert String to NodeList using another XPath function? Ideally, it will convert the String to a NodeList with one element which text content would be the String value. I tried with exsl:node-set() but with no success (Saxon-HE processor).
No, XPath is just a query language for XML documents -- it doesn't create nodes.
If the legacy code expects the XPath expression to evaluate to a NodeList and the result of evaluationg your XPath expression is just a string, then to reuse that legacy code without writing new code, you must change your XPath expression, so that it selects one or more nodes.
Or, write your own code that uses the result of the evaluation of the XPath expression.