简体   繁体   中英

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

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM