XUpdate processor xpath evaluation bug?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

XUpdate processor xpath evaluation bug?

Peter.Heintz
Hello all,

When I do an xpath evaluation like the following I receive a ?NaN? error.
select="(/ROWNUMBER  div (doc('input:InstanceDataUpdate')/FORM/CONTROL/PAGE_SIZE))"


By changing the expression as follows I receive a number but a wrong on.

select="(/ROWNUMBER * 1 div (doc('input:InstanceDataUpdate')/FORM/CONTROL/PAGE_SIZE))"


I did a workaround by using a xslt processor and all works fine, so I assume there is a bug in this xpath evaluation

-Peter



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: XUpdate processor xpath evaluation bug?

Erik Bruchez
Administrator
[hidden email] wrote:

 > When I do an xpath evaluation like the following I receive a 'NaN' error.
 > select="(/ROWNUMBER  div
(doc('input:InstanceDataUpdate')/FORM/CONTROL/PAGE_SIZE))"

You can as a first step make sure you convert nodes to an XPath number
type, as follows:

select="(number(/ROWNUMBER) div
number(doc('input:InstanceDataUpdate')/FORM/CONTROL/PAGE_SIZE))"

Now if the text value of /ROWNUMBER or that of
doc('input:InstanceDataUpdate')/FORM/CONTROL/PAGE_SIZE is not a
number, you will get the "NaN" result anyway.

 > By changing the expression as follows I receive a number but a wrong on.
 >
 > select="(/ROWNUMBER * 1 div
(doc('input:InstanceDataUpdate')/FORM/CONTROL/PAGE_SIZE))"

What is the content of / and doc('input:InstanceDataUpdate')?

 > I did a workaround by using a xslt processor and all works fine, so
 > I assume there is a bug in this xpath evaluation

If you use "oxf:xslt", you will use by defaul Saxon, which uses XPath
2.0 or an XPath 1.0 compatibility mode which may introduce some
difference of behavior compared to a plain XPath 1.0 engine. If you
send the two XML documents as asked above, maybe we can track down the
exact reason.

-Erik



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Re: XUpdate processor xpath evaluation bug?

Peter.Heintz
Hello,
I am quiet sure that my data are numbers because of the xslt processor do give me a the right number and not a ?NaN? back.

I prepared a shored test pipeline showing the differences.

Here is the pipeline:
<?xml version="1.0" encoding="ISO-8859-1"?>
<p:config   xmlns:p="http://www.orbeon.com/oxf/pipeline"
            xmlns:oxf="http://www.orbeon.com/oxf/processors">

   

    <p:processor name="oxf:identity">
        <p:input name="data">
            <value>2</value>
        </p:input>
        <p:output name="data" id="value1"/>
    </p:processor>
    <p:processor name="oxf:identity">
        <p:input name="data">
            <value>40</value>
        </p:input>
        <p:output name="data" id="value2"/>
    </p:processor>
   
    <p:processor name="oxf:xupdate" xmlns:xu="http://www.xmldb.org/xupdate">
        <p:input name="data" href="#value1"/>
        <p:input name="value2" href="#value2"/>
        <p:input name="config">
            <xu:modification>
                    <xu:update select="/">
                       <result>
                        <xu:value-of select="doc('input:value2')/value div /value"/>
                       </result>
                    </xu:update>
            </xu:modification>
        </p:input>
        <p:output name="data" id="resultxupdate"/>
    </p:processor>
    <p:processor name="oxf:null-serializer">
        <p:input name="data" href="#resultxupdate" debug="true"/>
    </p:processor>

    <p:processor name="oxf:xslt" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <p:input name="data" href="#value1"/>
      <p:input name="value2" href="#value2"/>
      <p:input name="config">
          <xsl:stylesheet version="2.0">
              <xsl:template match="/">
                  <result>
                      <xsl:value-of select="doc('input:value2')/value div /value"/>
                  </result>
              </xsl:template>
          </xsl:stylesheet>
      </p:input>
      <p:output name="data" id="resultxslt"/>
    </p:processor>    

    <p:processor name="oxf:null-serializer">
        <p:input name="data" href="#resultxslt" debug="true"/>
    </p:processor>
</p:config>



This is the debug output:

2005-09-29 17:27:59,389 INFO  org.orbeon.oxf.pipeline.InitUtils null - /xupdate - Received request
2005-09-29 17:27:59,420 INFO  org.orbeon.oxf.processor.DebugProcessor null - true:
oxf:/Start/xupdatetest.xpl, line 35, column 66

<result>1</result>
2005-09-29 17:27:59,435 INFO  org.orbeon.oxf.processor.DebugProcessor null - true:
oxf:/Start/xupdatetest.xpl, line 54, column 63

<result xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:p="http://www.orbeon.com/oxf/pipeline">20</result>
2005-09-29 17:27:59,435 INFO  org.orbeon.oxf.pipeline.InitUtils null - /xupdate - Timing: 46 - Cache hits: 59, fault: 5, adds: 6, success rate: 92%

Any ideas ?

-Peter




When I do an xpath evaluation like the following I receive a 'NaN' error.
> select="(/ROWNUMBER div (doc('input:InstanceDataUpdate')/FORM/CONTROL/PAGE_SIZE))"

You can as a first step make sure you convert nodes to an XPath number
type, as follows:

select="(number(/ROWNUMBER) div number(doc('input:InstanceDataUpdate')/FORM/CONTROL/PAGE_SIZE))"

Now if the text value of /ROWNUMBER or that of
doc('input:InstanceDataUpdate')/FORM/CONTROL/PAGE_SIZE is not a
number, you will get the "NaN" result anyway.

> By changing the expression as follows I receive a number but a wrong on.
>
> select="(/ROWNUMBER * 1 div (doc('input:InstanceDataUpdate')/FORM/CONTROL/PAGE_SIZE))"

What is the content of / and doc('input:InstanceDataUpdate')?

> I did a workaround by using a xslt processor and all works fine, so
> I assume there is a bug in this xpath evaluation

If you use "oxf:xslt", you will use by defaul Saxon, which uses XPath
2.0 or an XPath 1.0 compatibility mode which may introduce some
difference of behavior compared to a plain XPath 1.0 engine. If you
send the two XML documents as asked above, maybe we can track down the
exact reason.

-Erik



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: XUpdate processor xpath evaluation bug?

Erik Bruchez
Administrator
Hi Peter,

I reproduced this and it is clearly a bug. I suspect the context node is
incorrectly set. I entered a bug to track this:

https://forge.objectweb.org/tracker/index.php?func=detail&aid=304140&group_id=168&atid=350207

A workaround is to do something like this instead:

<p:processor name="oxf:xupdate" xmlns:xu="http://www.xmldb.org/xupdate">
     <p:input name="data"><dummy/></p:input>
     <p:input name="value1" href="#value1"/>
     <p:input name="value2" href="#value2"/>
     <p:input name="config">
         <xu:modification>
             <xu:update select="/">
                <result>
                     <xu:value-of select="doc('input:value2')/value div
doc('input:value1')/value"/>
                </result>
             </xu:update>
         </xu:modification>
     </p:input>
     <p:output name="data" id="resultxupdate"/>
</p:processor>

-Erik

[hidden email] wrote:

> Hello,
> I am quiet sure that my data are numbers because of the xslt processor do give me a the right number and not a ?NaN? back.
>
> I prepared a shored test pipeline showing the differences.
>
> Here is the pipeline:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <p:config   xmlns:p="http://www.orbeon.com/oxf/pipeline"
>             xmlns:oxf="http://www.orbeon.com/oxf/processors">
>
>    
>
>     <p:processor name="oxf:identity">
>         <p:input name="data">
>             <value>2</value>
>         </p:input>
>         <p:output name="data" id="value1"/>
>     </p:processor>
>     <p:processor name="oxf:identity">
>         <p:input name="data">
>             <value>40</value>
>         </p:input>
>         <p:output name="data" id="value2"/>
>     </p:processor>
>    
>     <p:processor name="oxf:xupdate" xmlns:xu="http://www.xmldb.org/xupdate">
>         <p:input name="data" href="#value1"/>
>         <p:input name="value2" href="#value2"/>
>         <p:input name="config">
>             <xu:modification>
>                     <xu:update select="/">
>                        <result>
>                         <xu:value-of select="doc('input:value2')/value div /value"/>
>                        </result>
>                     </xu:update>
>             </xu:modification>
>         </p:input>
>         <p:output name="data" id="resultxupdate"/>
>     </p:processor>
>     <p:processor name="oxf:null-serializer">
>         <p:input name="data" href="#resultxupdate" debug="true"/>
>     </p:processor>
>
>     <p:processor name="oxf:xslt" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>       <p:input name="data" href="#value1"/>
>       <p:input name="value2" href="#value2"/>
>       <p:input name="config">
>           <xsl:stylesheet version="2.0">
>               <xsl:template match="/">
>                   <result>
>                       <xsl:value-of select="doc('input:value2')/value div /value"/>
>                   </result>
>               </xsl:template>
>           </xsl:stylesheet>
>       </p:input>
>       <p:output name="data" id="resultxslt"/>
>     </p:processor>    
>
>     <p:processor name="oxf:null-serializer">
>         <p:input name="data" href="#resultxslt" debug="true"/>
>     </p:processor>
> </p:config>
>
>
>
> This is the debug output:
>
> 2005-09-29 17:27:59,389 INFO  org.orbeon.oxf.pipeline.InitUtils null - /xupdate - Received request
> 2005-09-29 17:27:59,420 INFO  org.orbeon.oxf.processor.DebugProcessor null - true:
> oxf:/Start/xupdatetest.xpl, line 35, column 66
>
> <result>1</result>
> 2005-09-29 17:27:59,435 INFO  org.orbeon.oxf.processor.DebugProcessor null - true:
> oxf:/Start/xupdatetest.xpl, line 54, column 63
>
> <result xmlns:oxf="http://www.orbeon.com/oxf/processors" xmlns:p="http://www.orbeon.com/oxf/pipeline">20</result>
> 2005-09-29 17:27:59,435 INFO  org.orbeon.oxf.pipeline.InitUtils null - /xupdate - Timing: 46 - Cache hits: 59, fault: 5, adds: 6, success rate: 92%
>
> Any ideas ?
>
> -Peter
>
>
>
>
> When I do an xpath evaluation like the following I receive a 'NaN' error.
>
>>select="(/ROWNUMBER div (doc('input:InstanceDataUpdate')/FORM/CONTROL/PAGE_SIZE))"
>
>
> You can as a first step make sure you convert nodes to an XPath number
> type, as follows:
>
> select="(number(/ROWNUMBER) div number(doc('input:InstanceDataUpdate')/FORM/CONTROL/PAGE_SIZE))"
>
> Now if the text value of /ROWNUMBER or that of
> doc('input:InstanceDataUpdate')/FORM/CONTROL/PAGE_SIZE is not a
> number, you will get the "NaN" result anyway.
>
>
>>By changing the expression as follows I receive a number but a wrong on.
>>
>>select="(/ROWNUMBER * 1 div (doc('input:InstanceDataUpdate')/FORM/CONTROL/PAGE_SIZE))"
>
>
> What is the content of / and doc('input:InstanceDataUpdate')?
>
>
>>I did a workaround by using a xslt processor and all works fine, so
>>I assume there is a bug in this xpath evaluation
>
>
> If you use "oxf:xslt", you will use by defaul Saxon, which uses XPath
> 2.0 or an XPath 1.0 compatibility mode which may introduce some
> difference of behavior compared to a plain XPath 1.0 engine. If you
> send the two XML documents as asked above, maybe we can track down the
> exact reason.
>
> -Erik
>
>
>
> ------------------------------------------------------------------------
>
>
> --
> You receive this message as a subscriber of the [hidden email] mailing list.
> To unsubscribe: mailto:[hidden email]
> For general help: mailto:[hidden email]?subject=help
> ObjectWeb mailing lists service home page: http://www.objectweb.org/wws



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Baisc xforms questions

Pascal Heus
In reply to this post by Peter.Heintz
Hi,
I'm just getting started with xforms (using OPS 3.0) and have a couple
of questions.

#1 I have a simple search xform that I validate using type/constraints.
This works very well until I add an action to the page to copy the form
instance to the next processing page (see below). I guess this tell OPS
to go straight to my search. results page and it skips the validation
process. How can I make sure the form gets validated before going to the
result page? Saw something about @xxforms:valid but not sure if its the
right thing to use.

#2 When I copy the form instance from one page to the next using
xupdate, is there a way to update the whole form at once instead of
element by element. For example, in the case show below, this does not
seem to work:
<xu:update select="/form/ddi">
    <xu:value-of select="document('oxf:instance')/form/ddi"/>
</xu:update>
I need an xupdate statement for each element.

many thanks
<P/>


This works:
<page path-info="/catalog/search" view="search-view.xsl"
xforms="search-xform.xml"/>

This prevents the xform from being valudated:
<page path-info="/catalog/search" view="search-view.xsl"
xforms="search-xform.xml">
        <action when="/form/action='search_files'">
            <result page="surveys">
                <xu:update select="/form/ddi/title">
                    <xu:value-of
select="document('oxf:instance')/form/ddi/title"/>
                </xu:update>
                <xu:update select="/form/ddi/country">
                    <xu:value-of
select="document('oxf:instance')/form/ddi/country"/>
                </xu:update>
                <xu:update select="/form/ddi/yearFrom">
                    <xu:value-of
select="document('oxf:instance')/form/ddi/yearFrom"/>
                </xu:update>
                <xu:update select="/form/ddi/yearTo">
                    <xu:value-of
select="document('oxf:instance')/form/ddi/yearTo"/>
                </xu:update>
                <xu:update select="/form/ddi/surveyKeywords">
                    <xu:value-of
select="document('oxf:instance')/form/ddi/surveyKeywords"/>
                </xu:update>
                <xu:update select="/form/ddi/dataKeywords">
                    <xu:value-of
select="document('oxf:instance')/form/ddi/dataKeywords"/>
                </xu:update>
            </result>
        </action>
    </page>



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: Baisc xforms questions

Erik Bruchez
Administrator
Pascal,

 > #1 I have a simple search xform that I validate using type/constraints.
 > This works very well until I add an action to the page to copy the form
 > instance to the next processing page (see below). I guess this tell OPS
 > to go straight to my search. results page and it skips the validation
 > process. How can I make sure the form gets validated before going to the
 > result page? Saw something about @xxforms:valid but not sure if its the
 > right thing to use.

Looking at your page flow configuration, you are using the XForms
Classic engine. The BizDoc Classic example shows how to do this under
bizdoc/page-flow.xml: here you detect through annotations that the
XForms engine places on the submitted instance
(@xxforms:valid="false", for example) that the form is not valid, and
do not go to another page if the form is invalid:

<action when="/form/action = 'save'
               and not(/form/document//*[@xxforms:valid = 'false')"
         action="detail/save-document-action.xpl">
   ...
</action>

etc.

With XForms NG, it is way easier, as the XForms instance simply cannot
be submitted if it contains errors. In that case, you can catch the
xforms-submit-error event and take some action.

 > #2 When I copy the form instance from one page to the next using
 > xupdate, is there a way to update the whole form at once instead of
 > element by element. For example, in the case show below, this does not
 > seem to work:
 > <xu:update select="/form/ddi">
 >    <xu:value-of select="document('oxf:instance')/form/ddi"/>
 > </xu:update>
 > I need an xupdate statement for each element.

Sure, you can do something like what is done in the BizDoc Classic
example:

<result page="detail-1">
     <xu:remove select="/*"/>
     <xu:update select="/">
         <xu:copy-of select="document('input:instance')/*"/>
     </xu:update>
     <xu:update select="/form/action"/>
     <xu:update select="/form/message">save-success</xu:update>
</result>

For a good comparison between the "Classic" and "NG" ways, compare the
BizDoc Classic and BizDoc NG examples.

Note that with OPS 3.0, you can now use XSLT or XQuery to create an
XML submission for the destination page. In that case, you could do
something like:

<result page="detail-1" transform="oxf:xslt">

     <!-- Create here XSLT stylesheet that creates your destination XML
     document, using doc('input:instance') to access the currently
     submitted XForms instance -->

     ...

</result>

-Erik




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws