Re: Checking if an extension function exists and implementation/version sniffing

Eric,

A way to detect individual XPath functions would be good.

Ideally, there would be a try/catch in XPath, and with an evaluate()
function you could then dynamically test what works and what doesn't.
But there isn't, even with XPath 3 (XQuery 3 does have that though).

Short of this With Orbeon Forms, an action which fails dispatches an
event xxforms-action-error. That with saxon:evaluate() might allow
testing on individual functions.

-Erik

On Thu, Sep 19, 2013 at 6:20 AM, Eric van der Vlist <vdv@dyomedea.com> wrote:
> To differentiate between Orbeon Forms,betterFORM and XSLTForms the
> following seems to be working:
>
> <?xml version="1.0" encoding="utf-8"?>
> <html xmlns="http://www.w3.org/1999/xhtml"
> xmlns:xf="http://www.w3.org/2002/xforms"
>     xmlns:xxf="http://orbeon.org/oxf/xml/xforms"
> xmlns:ev="http://www.w3.org/2001/xml-events">
>     <head>
>         <title>Implementation/version sniffing</title>
>         <xf:model id="model">
>             <xf:instance id="instance" xmlns="">
>                 <snif>
>                     <tests>
>                         <xpath10></xpath10>
>                         <context></context>
>                     </tests>
>                     <implementations>
>                         <betterform></betterform>
>                         <xsltforms></xsltforms>
>                         <orbeon></orbeon>
>                     </implementations>
>                     <implementation></implementation>
>                 </snif>
>             </xf:instance>
>             <xf:bind ref="instance()">
>                 <xf:bind nodeset="tests">
>                     <xf:bind nodeset="xpath10" calculate="'1' =
> '1.0'"></xf:bind>
>                     <xf:bind nodeset="context"
> id="context-bind"></xf:bind>
>                 </xf:bind>
>                 <xf:bind nodeset="implementations">
>                     <xf:bind nodeset="betterform"
>                         calculate="/snif/tests/xpath10='false' and
> not(/snif/tests/context = 'true')"></xf:bind>
>                     <xf:bind nodeset="xsltforms"
> calculate="/snif/tests/xpath10"></xf:bind>
>                     <xf:bind nodeset="orbeon"
> calculate="/snif/tests/xpath10='false' and /snif/tests/context = 'true'"
>                     ></xf:bind>
>                 </xf:bind>
>                 <xf:bind nodeset="implementation"
> calculate="name(/snif/implementations/*[. = 'true'])"></xf:bind>
>             </xf:bind>
>             <xf:dispatch ev:event="xforms-ready" name="context-event"
> targetid="model">
>                 <xxf:context name="context"
> select="true()"></xxf:context>
>             </xf:dispatch>
>             <xf:setvalue ev:event="context-event" bind="context-bind"
> value="event('context')"></xf:setvalue>
>         </xf:model>
>     </head>
>     <body>
>         <xf:output ref="implementation">
>             <xf:label>implementation: </xf:label>
>         </xf:output>
>         <ul>
>             <xf:repeat nodeset="*/*">
>                 <li>
>                     <xf:output ref=".">
>                         <xf:label>
>                             <xf:output value="concat(name(), ':
> ')"></xf:output>
>                         </xf:label>
>                     </xf:output>
>                 </li>
>             </xf:repeat>
>         </ul>
>     </body>
> </html>
>
> (http://xformsunit.org/trac/browser/resources/sandbox/sniffing.xhtml )
>
> Reminds me of the ugliness of browsers sniffing though and I wish we
> could have something better ;) ...
>
> Thanks,
>
> Eric
>
>
> Le jeudi 19 septembre 2013 à 11:38 +0200, Eric van der Vlist a écrit :
>> Hi,
>>
>> My test framework (http://xformsunit.org/) is trying hard to work with
>> several XForms implementations using generic/standard XForms features
>> but I get a number of interoperability issues and I would need to test
>> if extension functions are available in the implementation that's
>> running a form (or a test suite) and/or to identify the implementation.
>>
>> The mechanism to do so in XForms 1.1
>> (http://www.w3.org/TR/xforms11/#expr-lib-extension ) seems to be rather
>> "destructive" as it would stop any processing when a function is not
>> available.
>>
>> Do you have any idea on how I can achieve this kind of things?
>>
>> Thanks,
>>
>> Eric
>>
>>
>>
>>
>
>
>

Received on Thursday, 19 September 2013 14:56:36 UTC