Is there a method to invoke xQuery function from a textlist using saxon?

78 Views Asked by At

I have the below XML

<?xml version="1.0" encoding="UTF-8"?>
    <SpecializedActions>
        <SpecializedAction>
            <Name>ActivateAAA_Account</Name>
            <Function>holaaalib:activate($csmHeader, $component, $taskName, $osmOrderId)</Function>
        </SpecializedAction>
        <SpecializedAction>
            <Name>ActivateIMSAccount</Name>
            <Function>imsLib:activate($csmHeader, $component, $taskName, $osmOrderId)</Function>
        </SpecializedAction>
    </SpecializedActions>

and i tried to invoke the functions in my generic xQuery like this

if (fn:exists($specializedAList/SpecializedAction[Name/text() = $specializedActionName])) then
    $specializedAList/SpecializedAction[Name/text() = $specializedActionName]/Function/text()

but that way it will return a text 'imsLib:activate($csmHeader, $component, $taskName, $osmOrderId)'. Is there a method to cast it as an xQuery expression?

1

There are 1 best solutions below

0
On

XSLT 3.0 has an instruction xsl:evaluate which can be used to evaluate an XPath expression read from a source document (or conjured up at run-time in some other way). There's no standard equivalent in XQuery (though in principle you could do it using fn:transform() which dynamically invokes an XSLT transformation.

Saxon-PE and higher have an extension saxon:evaluate() which does much the same thing, and can be invoked from XQuery.