xforms

Get name of submission in event (xforms-submit-error)


I'm trying to make some generic handle of all submission with end with error.

It is possible to get name (id or something unique) of submission in event xforms-submit-error?

I already make my own custom model witch can catch and store metadata of failed submission. What is left me to deal with is how to get name of submission. I need somehow separate each call. I cant use uri because I sometimes call same uri multiple times in form. Here is my code:

   <xf:model  xmlns:xf="http://www.w3.org/2002/xforms" id="my-model">
        <xf:instance id="my-error-instance">
            <reponseList>
            </reponseList>
        </xf:instance>
        <xf:instance id="my-error-template-instance">
            <submission>
                <name/>
                <error-type/>
                <status-code/>
                <uri/>
                <content-lenght/>
                <body/>
            </submission>
        </xf:instance>
        <xf:action observer="my-main-model" event="xforms-submit-error">
           <xf:insert context="xxf:instance('my-error-instance')" ref="reponseList" origin="xxf:instance('my-error-template-instance')"/>
                   
            <xf:setvalue ref="xxf:instance('my-error-instance')//submission[1]/name" value="THIS_IS_WHAT_I_WANT"/>      
            <xf:setvalue ref="xxf:instance('my-error-instance')//submission[1]/error-type" value="event('error-type')"/>                
            <xf:setvalue ref="xxf:instance('my-error-instance')//submission[1]/status-code" value="event('response-status-code')"/>
            <xf:setvalue ref="instance('my-error-instance')/uri" value="event('resource-uri')"/>
            <!-- content-length or any relevant header -->
            <xf:setvalue ref="instance('my-error-instance')/content-lenght" value="event('response-headers')[lower-case(name) = 'content-length']/value"/>       
            <xf:setvalue ref="instance('my-error-instance')/body" value="event('response-body')"/>           
        </xf:action>
    </xf:model>

I have observer set to my-main-model witch is main model of my forms. So this event hit every failed submission. For every failed submission it add new structure from template and fill with metadata. I need somehow fill element name...


Solution

  • I find that i can use event('target'). It return name of submission which fire xforms-submit-error. I dont know if is it pure XForms or it is only in Orbeon, but it work form me well.