Orbeon's implementation of itemset element not able to traverse elements with namespaces?

StackOverflow https://stackoverflow.com/questions/4818800

  •  26-10-2019
  •  | 
  •  

Question

I am trying to run this code:

<xforms:select1 xmlns:xbl="http://www.w3.org/ns/xbl"
                                            xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
                                            xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary"
                                            appearance="xxforms:tree"
                                            bind="retrievalControl-bind"
                                            id="retrievalControl-control-laidOut">
<xforms:label ref="$form-resources/retrievalControl/label"/>
<xforms:help ref="$form-resources/retrievalControl/help"/>
<xforms:itemset nodeset="instance('fr-form-instance')/retrievalSection/retrievalControl/*/*/APP">
    <xforms:label ref="NAME"/>
    <xforms:value />
</xforms:itemset>

where retrievalControl contains this document:

<?xml version="1.0" encoding="utf-8"?><jax-rx:results xmlns:jax-rx="http://jax-rx.sourceforge.net"><jax-rx:result><APP count="1">
        <NAME>ABCD</NAME>
        <ID>12</ID>
    </APP>
</jax-rx:result></jax-rx:results>

But it does not work (no items created for select1). If I remove / */ */APP, so as to print the whole document as an item label (by modifying label to ref=".", it spews out the data.

Cannot figure out why it can't traverse the elements which have jax-rx specified as ns...any workarounds (the query works fine in XMLSpy)?

Update based on the earliest response (Jan 27) below:

<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
        xmlns:xforms="http://www.w3.org/2002/xforms"
        xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
        xmlns:ev="http://www.w3.org/2001/xml-events"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:fr="http://orbeon.org/oxf/xml/form-runner">
<xhtml:head>
    <xforms:model>
        <xforms:instance>
            <instance>
                <weird/>
            </instance>
        </xforms:instance>
        <xforms:instance id="fr-form-instance">
            <form>
                <retrievalSection>
                    <retrievalControl>
                        <jax-rx:results xmlns:jax-rx="http://jax-rx.sourceforge.net">
                            <jax-rx:result>
                                <APP count="1">
                                    <NAME>ABCD</NAME>
                                    <ID>12</ID>
                                </APP>
                            </jax-rx:result>
                        </jax-rx:results>
                    </retrievalControl>
                </retrievalSection>
            </form>
        </xforms:instance>
        <xforms:bind id="fr-form-binds" nodeset="instance('fr-form-instance')">
            <xforms:bind id="retrievalSection-bind" nodeset="retrievalSection" name="retrievalSection">
                <xforms:bind id="retrievalControl-bind" nodeset="retrievalControl" name="retrievalControl"/>
            </xforms:bind>
        </xforms:bind>
        <xforms:submission resource="http://AURLWhereOurExampleDataFileIsAvailale"
                           method="get"
                           id="getData"
                           replace="text"
                           instance="fr-form-instance"
                           targetref="/instance/weird"
                           serialization="none">
            <xforms:message ev:event="xforms-submit-error" level="modal">A submission error occurred:<xforms:output value="event('error-type')"/>
            </xforms:message>
        </xforms:submission>
        <xforms:send ev:event="xforms-ready" submission="getData"/>
    </xforms:model>
</xhtml:head>
<xhtml:body>
    <xforms:select1 xmlns:xbl="http://www.w3.org/ns/xbl"
                    xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
                    xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary"
                    appearance="xxforms:tree"
                    bind="retrievalControl-bind"
                    id="retrievalControl-control-laidOut">
        <xforms:itemset nodeset="instance('fr-form-instance')">
            <!--<xforms:itemset nodeset="instance('fr-form-instance')/retrievalSection/retrievalControl/*/*/APP">-->
            <!--<xforms:itemset nodeset="instance()/*/*/APP">-->
            <xforms:label ref="."/>
            <xforms:value/>
        </xforms:itemset>
    </xforms:select1>
</xhtml:body>

I investigated the problem further based on the 1st response below and the problem seems not with the ability to parse elements with namespaces, but perhaps with how the XForms Submission has been implemented (or my poor understanding, in which case I request be corrected via a response to this question). The problem with XForms Submission is faulty instance replacement when attempted with replace="text", but probably also affects replace="instance", it appears replacement occurs a) on only the default instance and b) it occurs incorrectly compared to what the spec says, which is (from http://www.w3.org/TR/xforms11/#submit-data-replacement):

If the replace attribute contains the value "text" and the submission response conforms to an XML mediatype (as defined by the content type specifiers in [RFC 3023]) or a text media type (as defined by a content type specifier of text/*), then the response data is encoded as text and replaces the content of the replacement target node.

Okay, this can be proved by populating the whole content of the instance in an item-label in select1, note that the submission ID getData in above is attempting to replace a targetref which does not even exist in the instance ID referenced, but it works (it does not work if I put the targetref correctly for the instance ID referenced; in other words, it works only if the targetref points to a valid node in the 'default' instance (which happens to be the first instance), not the instance ID referenced. And even when it works, it does not replace the content in the targetref node (and I do not know where exactly it (submission replacement mechanism of Orbeon) places that content, all I know is it places that content somewhere in the default instance, but where - in a newly created text node?)

You will need to modify submission resource to a URL where the example data-file is available, sorry could not make it more self-contained.

Was it helpful?

Solution

XForms 1.1 says about targetref:

"The in-scope evaluation context of the submission element is used to evaluate the expression".

You write in your example:

<xforms:submission resource="http://AURLWhereOurExampleDataFileIsAvailale"
                   method="get"
                   id="getData"
                   replace="text"
                   instance="fr-form-instance"
                   targetref="/instance/weird"
                   serialization="none">

The instance attribute does not modify the in-scope evaluation context (as far as I can read the spec), so here targetref it's not relative to the instance attribute, but to the submission's in-scope evaluation context, which, since you did not specify a ref attribute, is the default (first) instance.

Basically, if you use targetref, don't use instance as things then get confusing.

So remove the instance attribute, and write targetref="instance('fr-form-instance')/weird".

Now if you do this with your updated example above, you will get an xforms-submit-error, as the node doesn't exist in the second instance.

Let's see if this gets you further.

OTHER TIPS

I suspect that <retrievalControl> does not really contain that <jax-rx:results> as you expect it to. If I create a stand-alone example which puts together the pieces you pasted, everything works as expected (see below). Would you have a complete (and as minimal as possible) example that reproduces this?

<xhtml:html xmlns:xhtml="http://www.w3.org/1999/xhtml"
            xmlns:xforms="http://www.w3.org/2002/xforms"
            xmlns:xxforms="http://orbeon.org/oxf/xml/xforms"
            xmlns:ev="http://www.w3.org/2001/xml-events"
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:fr="http://orbeon.org/oxf/xml/form-runner">
    <xhtml:head>
        <xforms:model>
            <xforms:instance>
                <instance>
                    <select1/>
                    <jax-rx:results xmlns:jax-rx="http://jax-rx.sourceforge.net">
                        <jax-rx:result>
                            <APP count="1">
                                <NAME>ABCD</NAME>
                                <ID>12</ID>
                            </APP>
                        </jax-rx:result>
                    </jax-rx:results>
                </instance>
            </xforms:instance>
        </xforms:model>
    </xhtml:head>
    <xhtml:body>
        <xforms:select1 xmlns:xbl="http://www.w3.org/ns/xbl"
                        xmlns:fb="http://orbeon.org/oxf/xml/form-builder"
                        xmlns:pipeline="java:org.orbeon.oxf.processor.pipeline.PipelineFunctionLibrary"
                        appearance="xxforms:tree"
                        ref="select1"
                        id="retrievalControl-control-laidOut">
            <xforms:itemset nodeset="instance()/*/*/APP">
                <xforms:label ref="NAME"/>
                <xforms:value/>
            </xforms:itemset>
        </xforms:select1>
    </xhtml:body>
</xhtml:html>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top