FW: XFOrms/XPath Parsing one data element into two controls for editing

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

RE: Xpath

Richard Braman
Daniel, this code also returns Array out of Bounds.  Error 3.  Error 3
is the sick world.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Daniel
E. Renfer
Sent: Thursday, February 23, 2006 4:12 PM
To: [hidden email]
Subject: Re: [ops-users] Xpath


What about doing it something like:

/f1040ez/taxtable//item[xs:decimal(/f1040ez/income) ge
xs:decimal(income-equal-or-greater-than) and xs:decimal(/f1040ez/income)
lt xs:decimal(income-less-than)]/*[((name() eq 'tax-single') and
(instance('main-instance')//f1040ez/filing-status eq '1')) or ((name()
eq 'tax-married-filing-jointly') and
(instance('main-instance')//f1040ez/filing-status eq '2'))]

The only question then becomes is doing it all as one query with the
*[name() = 'foo'] syntax any faster than using 2 loops and using /foo?

Thank you Erik for finding the xs:decimal problem, I was pulling my hair
out trying to figure out in what kind of sick world was 6 greater than
10.

Daniel E. Renfer (http://kronkltd.net/)

On 2/23/06, Erik Bruchez <[hidden email]> wrote:

> This exception is likely a bug in Saxon. You may be able to work
> around it by using a sequence instead of "|", i.e. instead of:
>
>    a | b
>
> write:
>
>    (a, b)
>
> -Erik
>
> Richard Braman wrote:
> > I knew it had to be a type issue (see previous post).  I further
> > modified the Xpath and it works in the sandbox as needed.  Its
> > actually quite close to Daniels code from last night.  But, I put
> > the code in calculate and it bombs with the same error
> >
> > java.lang.ArrayIndexOutOfBoundsException
> > Exception Class java.lang.ArrayIndexOutOfBoundsException
> > Message 3
> > Servlet Stack Trace
> > (177 method calls)  Class Name Method Name File Name Line Number
> > org.orbeon.saxon.expr.XPathContextMajor setLocalVariable
> > XPathContextMajor.java 213
> >
> >
> > Calculate=
> >
> >                       instance('taxtable')
> >                       //taxtable/item
> >
> > [xs:integer(instance('main-instance')//f1040ez/filing-status) eq 1]
> >                       [
> >
> > xs:decimal(instance('main-instance')//f1040ez/income) ge
> > xs:decimal(income-equal-or-greater-than)
> >                       ]
> >                       [
> >
> > xs:decimal(instance('main-instance')//f1040ez/income) lt
> > xs:decimal(income-less-than)
> >                       ]
> >                       /tax-single
> >
> >                       |
> >
> >                        instance('taxtable')
> >                        //taxtable/item
> >
> > [xs:integer(instance('main-instance')//f1040ez/filing-status) eq 2]
> >                        [
> >
> > xs:decimal(instance('main-instance')//f1040ez/income) gt
> > xs:decimal(income-equal-or-greater-than)
> >                       ]
> >                       [
> >
> > xs:decimal(instance('main-instance')//f1040ez/income) lt
> > xs:decimal(income-less-than)
> >                        ]
> >                        /tax-married-filing-jointly
> >
> >
> >
> > ***********************************************
> >
> > Xquery:
> >
> > <result>
> >      {
> >      /f1040ez/taxtable//item[xs:integer(/f1040ez/filing-status) eq
> > 1][xs:decimal(/f1040ez/income) ge
> > xs:decimal(income-equal-or-greater-than) and
> > xs:decimal(/f1040ez/income)
> >
> > lt xs:decimal(income-less-than)]/tax-single |
> >      /f1040ez/taxtable//item[xs:integer(/f1040ez/filing-status) eq
> > 2][xs:decimal(/f1040ez/income) ge
> > xs:decimal(income-equal-or-greater-than) and
> > xs:decimal(/f1040ez/income)
> >
> > lt xs:decimal(income-less-than)]/tax-married-filing-jointly
> >      }
> > </result>
> >
> > **************************************************
> >
> > Input:
> >
> > <f1040ez>
> >       <SEQ0010>123456789</SEQ0010>
> >       <SEQ0100>X</SEQ0100>
> >       <SEQ0110/>
> >       <filing-status>1</filing-status>
> >       <income>5</income>
> >       <tax/>
> >       <credit/>
> >       <titles>
> >               <sec2f>Section 2</sec2f>
> >               <sec1b>Section 1</sec1b>
> >       </titles>
> >       <taxtable>
> >               <item>
> >
> > <income-equal-or-greater-than>0</income-equal-or-greater-than>
> >                       <income-less-than>5</income-less-than>
> >                       <tax-single>2</tax-single>
> >
> > <tax-married-filing-jointly>4</tax-married-filing-jointly>
> >               </item>
> >               <item>
> >
> > <income-equal-or-greater-than>5</income-equal-or-greater-than>
> >                       <income-less-than>10</income-less-than>
> >                       <tax-single>4</tax-single>
> >
> > <tax-married-filing-jointly>6</tax-married-filing-jointly>
> >               </item>
> >       </taxtable>
> > </f1040ez>
> >
> >
> >
> >
> >
> > --------------------------------------------------------------------
> > ----
> >
> >
> > --
> > 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
>
>
>




--
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: Xpath

Richard Braman
The other thing I wonder is why it works in the Sandbox. Doesn't that
use Saxon too?

-----Original Message-----
From: Richard Braman [mailto:[hidden email]]
Sent: Thursday, February 23, 2006 4:14 PM
To: [hidden email]
Subject: RE: [ops-users] Xpath


Daniel, this code also returns Array out of Bounds.  Error 3.  Error 3
is the sick world.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Daniel
E. Renfer
Sent: Thursday, February 23, 2006 4:12 PM
To: [hidden email]
Subject: Re: [ops-users] Xpath


What about doing it something like:

/f1040ez/taxtable//item[xs:decimal(/f1040ez/income) ge
xs:decimal(income-equal-or-greater-than) and xs:decimal(/f1040ez/income)
lt xs:decimal(income-less-than)]/*[((name() eq 'tax-single') and
(instance('main-instance')//f1040ez/filing-status eq '1')) or ((name()
eq 'tax-married-filing-jointly') and
(instance('main-instance')//f1040ez/filing-status eq '2'))]

The only question then becomes is doing it all as one query with the
*[name() = 'foo'] syntax any faster than using 2 loops and using /foo?

Thank you Erik for finding the xs:decimal problem, I was pulling my hair
out trying to figure out in what kind of sick world was 6 greater than
10.

Daniel E. Renfer (http://kronkltd.net/)

On 2/23/06, Erik Bruchez <[hidden email]> wrote:

> This exception is likely a bug in Saxon. You may be able to work
> around it by using a sequence instead of "|", i.e. instead of:
>
>    a | b
>
> write:
>
>    (a, b)
>
> -Erik
>
> Richard Braman wrote:
> > I knew it had to be a type issue (see previous post).  I further
> > modified the Xpath and it works in the sandbox as needed.  Its
> > actually quite close to Daniels code from last night.  But, I put
> > the code in calculate and it bombs with the same error
> >
> > java.lang.ArrayIndexOutOfBoundsException
> > Exception Class java.lang.ArrayIndexOutOfBoundsException
> > Message 3
> > Servlet Stack Trace
> > (177 method calls)  Class Name Method Name File Name Line Number
> > org.orbeon.saxon.expr.XPathContextMajor setLocalVariable
> > XPathContextMajor.java 213
> >
> >
> > Calculate=
> >
> >                       instance('taxtable')
> >                       //taxtable/item
> >
> > [xs:integer(instance('main-instance')//f1040ez/filing-status) eq 1]
> >                       [
> >
> > xs:decimal(instance('main-instance')//f1040ez/income) ge
> > xs:decimal(income-equal-or-greater-than)
> >                       ]
> >                       [
> >
> > xs:decimal(instance('main-instance')//f1040ez/income) lt
> > xs:decimal(income-less-than)
> >                       ]
> >                       /tax-single
> >
> >                       |
> >
> >                        instance('taxtable')
> >                        //taxtable/item
> >
> > [xs:integer(instance('main-instance')//f1040ez/filing-status) eq 2]
> >                        [
> >
> > xs:decimal(instance('main-instance')//f1040ez/income) gt
> > xs:decimal(income-equal-or-greater-than)
> >                       ]
> >                       [
> >
> > xs:decimal(instance('main-instance')//f1040ez/income) lt
> > xs:decimal(income-less-than)
> >                        ]
> >                        /tax-married-filing-jointly
> >
> >
> >
> > ***********************************************
> >
> > Xquery:
> >
> > <result>
> >      {
> >      /f1040ez/taxtable//item[xs:integer(/f1040ez/filing-status) eq
> > 1][xs:decimal(/f1040ez/income) ge
> > xs:decimal(income-equal-or-greater-than) and
> > xs:decimal(/f1040ez/income)
> >
> > lt xs:decimal(income-less-than)]/tax-single |
> >      /f1040ez/taxtable//item[xs:integer(/f1040ez/filing-status) eq
> > 2][xs:decimal(/f1040ez/income) ge
> > xs:decimal(income-equal-or-greater-than) and
> > xs:decimal(/f1040ez/income)
> >
> > lt xs:decimal(income-less-than)]/tax-married-filing-jointly
> >      }
> > </result>
> >
> > **************************************************
> >
> > Input:
> >
> > <f1040ez>
> >       <SEQ0010>123456789</SEQ0010>
> >       <SEQ0100>X</SEQ0100>
> >       <SEQ0110/>
> >       <filing-status>1</filing-status>
> >       <income>5</income>
> >       <tax/>
> >       <credit/>
> >       <titles>
> >               <sec2f>Section 2</sec2f>
> >               <sec1b>Section 1</sec1b>
> >       </titles>
> >       <taxtable>
> >               <item>
> >
> > <income-equal-or-greater-than>0</income-equal-or-greater-than>
> >                       <income-less-than>5</income-less-than>
> >                       <tax-single>2</tax-single>
> >
> > <tax-married-filing-jointly>4</tax-married-filing-jointly>
> >               </item>
> >               <item>
> >
> > <income-equal-or-greater-than>5</income-equal-or-greater-than>
> >                       <income-less-than>10</income-less-than>
> >                       <tax-single>4</tax-single>
> >
> > <tax-married-filing-jointly>6</tax-married-filing-jointly>
> >               </item>
> >       </taxtable>
> > </f1040ez>
> >
> >
> >
> >
> >
> > --------------------------------------------------------------------
> > ----
> >
> >
> > --
> > 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
>
>
>






--
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: Xpath

Erik Bruchez
Administrator
In reply to this post by Daniel E. Renfer
Daniel E. Renfer wrote:

> Thank you Erik for finding the xs:decimal problem, I was pulling my
> hair out trying to figure out in what kind of sick world was 6 greater
> than 10.

A worlds of character strings... ;-)

-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: Xpath

Richard Braman
In reply to this post by Erik Bruchez
None of this works, you cant seem to have more than 1 element in whatver
array is being built by
org.orbeon.saxon.expr.XPathContextMajor setLocalVariable
XPathContextMajor.java 213 . The , and  | notation gets split up into an
array and the array is probably coded for 1 element only, why is a darn
good question.  I emailed the saxon list for more details.



-----Original Message-----
From: Erik Bruchez [mailto:[hidden email]] On Behalf Of Erik Bruchez
Sent: Thursday, February 23, 2006 3:41 PM
To: [hidden email]
Subject: Re: [ops-users] Xpath


This exception is likely a bug in Saxon. You may be able to work around
it by using a sequence instead of "|", i.e. instead of:

   a | b

write:

   (a, b)

-Erik

Richard Braman wrote:

> I knew it had to be a type issue (see previous post).  I further
> modified the Xpath and it works in the sandbox as needed.  Its
> actually quite close to Daniels code from last night.  But, I put the
> code in calculate and it bombs with the same error
>
> java.lang.ArrayIndexOutOfBoundsException
> Exception Class java.lang.ArrayIndexOutOfBoundsException
> Message 3
> Servlet Stack Trace
> (177 method calls)  Class Name Method Name File Name Line Number
> org.orbeon.saxon.expr.XPathContextMajor setLocalVariable
> XPathContextMajor.java 213
>  
>
> Calculate=
>
> instance('taxtable')
> //taxtable/item
>
> [xs:integer(instance('main-instance')//f1040ez/filing-status) eq 1]
> [
>
> xs:decimal(instance('main-instance')//f1040ez/income) ge
> xs:decimal(income-equal-or-greater-than)
> ]
> [
>
> xs:decimal(instance('main-instance')//f1040ez/income) lt
> xs:decimal(income-less-than)
> ]
> /tax-single
>
> |
>
> instance('taxtable')
> //taxtable/item
>  
> [xs:integer(instance('main-instance')//f1040ez/filing-status) eq 2]
> [
>
> xs:decimal(instance('main-instance')//f1040ez/income) gt
> xs:decimal(income-equal-or-greater-than)
> ]
> [
>
> xs:decimal(instance('main-instance')//f1040ez/income) lt
> xs:decimal(income-less-than)
> ]
> /tax-married-filing-jointly
>
>
>
> ***********************************************
>
> Xquery:
>
> <result>
>      {
>      /f1040ez/taxtable//item[xs:integer(/f1040ez/filing-status) eq
> 1][xs:decimal(/f1040ez/income) ge
> xs:decimal(income-equal-or-greater-than) and
xs:decimal(/f1040ez/income)
>
> lt xs:decimal(income-less-than)]/tax-single |
>      /f1040ez/taxtable//item[xs:integer(/f1040ez/filing-status) eq
> 2][xs:decimal(/f1040ez/income) ge
> xs:decimal(income-equal-or-greater-than) and
xs:decimal(/f1040ez/income)

>
> lt xs:decimal(income-less-than)]/tax-married-filing-jointly
>      }
> </result>
>
> **************************************************
>
> Input:
>
> <f1040ez>
> <SEQ0010>123456789</SEQ0010>
> <SEQ0100>X</SEQ0100>
> <SEQ0110/>
> <filing-status>1</filing-status>
> <income>5</income>
> <tax/>
> <credit/>
> <titles>
> <sec2f>Section 2</sec2f>
> <sec1b>Section 1</sec1b>
> </titles>
> <taxtable>
> <item>
>
> <income-equal-or-greater-than>0</income-equal-or-greater-than>
> <income-less-than>5</income-less-than>
> <tax-single>2</tax-single>
>
> <tax-married-filing-jointly>4</tax-married-filing-jointly>
> </item>
> <item>
>
> <income-equal-or-greater-than>5</income-equal-or-greater-than>
> <income-less-than>10</income-less-than>
> <tax-single>4</tax-single>
>
> <tax-married-filing-jointly>6</tax-married-filing-jointly>
> </item>
> </taxtable>
> </f1040ez>
>
>
>
>
>
> ----------------------------------------------------------------------
> --
>
>
> --
> 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
|

Re: Xpath

Erik Bruchez
Administrator
In reply to this post by Richard Braman
One uses XPath from within XSLT, the other one through the Saxon XPath API.

-Erik

Richard Braman wrote:
> The other thing I wonder is why it works in the Sandbox. Doesn't that
> use Saxon too?




--
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
123