Hello all,
On my Xform I have the following construction:
<xforms:output value="count(.[/a/b[@attr='something']//c = 'true'])"/>
And in my instance document, I have:
<ser:ciz xmlns="http://www.workflow4people.org/services" xmlns:ser="http://www.workflow4people.org/services"> <d>Me</d>
This count always returns 1 or zero. If no c-elements are set to true, a 0 is returned. If there's one ore more set to true, a 1 is returned, always.
What am I doing wrong?
Best, Robin -- 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 OW2 mailing lists service home page: http://www.ow2.org/wws |
What exactly are you trying to count? If you're looking to count the
element "<a>" then your syntax appears to be working as desired. If you wanting to count the number of <b> elements with a <c> element of true, then the syntax would be: count(./a/b[@attr='something' and c='true']) If you're trying to count the number of <c> elements that are true, you could use this: count(./a/b[@attr='something']//c[text()='true']) ------------------------------------------------------------------------ Jeremy Nix Senior Application Developer Cincinnati Children's Hospital Medical Center On 07/07/2010 07:25 AM, Robin Diederen wrote: > > Hello all, > > On my Xform I have the following construction: > > <xforms:output value="count(.[/a/b[@attr='something']//c = 'true'])"/> > > And in my instance document, I have: > > <ser:ciz xmlns="http://www.workflow4people.org/services" > xmlns:ser="http://www.workflow4people.org/services"> > > <a> > <b attr="something"> > <c xsi:type="xs:boolean">false</c> > > <d>Me</d> > </b> > > <b attr="something"> > <c xsi:type="xs:boolean">false</c> > <d>You</d> > </b> > </a> > > This count always returns 1 or zero. If no c-elements are set to true, > a 0 is returned. If there's one ore more set to true, a 1 is returned, > always. > > What am I doing wrong? > > Best, Robin > -- 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 OW2 mailing lists service home page: http://www.ow2.org/wws |
Hello Jeremy,
I'm trying the nr. of c-elements set to true.
Is the text function the thing I should be using? As the field is typed as a boolean...
Best, Robin -----Original message----- -- 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 OW2 mailing lists service home page: http://www.ow2.org/wws |
You don't have to use the text() method. You could also do this:
count(./a/b[@attr='something']//c[.='true']) As with many other things, I'm sure there are a dozen other ways of writing this type of XPath query. ------------------------------------------------------------------------ Jeremy Nix Senior Application Developer Cincinnati Children's Hospital Medical Center On 07/07/2010 09:30 AM, Robin Diederen wrote: > > Hello Jeremy, > > I'm trying the nr. of c-elements set to true. > > Is the text function the thing I should be using? As the field is > typed as a boolean... > > Best, Robin > > -----Original message----- > *From:* Jeremy Nix <[hidden email]> > *Sent:* Wed 07-07-2010 14:15 > *To:* [hidden email]; > *Subject:* [ops-users] Re: Question on Xpath Count? > > What exactly are you trying to count? If you're looking to count the > element "<a>" then your syntax appears to be working as desired. > If you > wanting to count the number of <b> elements with a <c> element of > true, > then the syntax would be: > > count(./a/b[@attr='something' and c='true']) > > If you're trying to count the number of <c> elements that are > true, you > could use this: > > count(./a/b[@attr='something']//c[text()='true']) > > > ------------------------------------------------------------------------ > Jeremy Nix > Senior Application Developer > Cincinnati Children's Hospital Medical Center > > On 07/07/2010 07:25 AM, Robin Diederen wrote: > > > > Hello all, > > > > On my Xform I have the following construction: > > > > <xforms:output value="count(.[/a/b[@attr='something']//c = > 'true'])"/> > > > > And in my instance document, I have: > > > > <ser:ciz xmlns="http://www.workflow4people.org/services" > > xmlns:ser="http://www.workflow4people.org/services"> > > > > <a> > > <b attr="something"> > > <c xsi:type="xs:boolean">false</c> > > > > <d>Me</d> > > </b> > > > > <b attr="something"> > > <c xsi:type="xs:boolean">false</c> > > <d>You</d> > > </b> > > </a> > > > > This count always returns 1 or zero. If no c-elements are set to > true, > > a 0 is returned. If there's one ore more set to true, a 1 is > returned, > > always. > > > > What am I doing wrong? > > > > Best, Robin > > > -- 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 OW2 mailing lists service home page: http://www.ow2.org/wws |
I see, thanks!
-----Oorspronkelijk bericht----- Van: Jeremy Nix [mailto:[hidden email]] Verzonden: woensdag 7 juli 2010 16:23 Aan: [hidden email] Onderwerp: [ops-users] Re: RE: Re: Question on Xpath Count? You don't have to use the text() method. You could also do this: count(./a/b[@attr='something']//c[.='true']) As with many other things, I'm sure there are a dozen other ways of writing this type of XPath query. ------------------------------------------------------------------------ Jeremy Nix Senior Application Developer Cincinnati Children's Hospital Medical Center On 07/07/2010 09:30 AM, Robin Diederen wrote: > > Hello Jeremy, > > I'm trying the nr. of c-elements set to true. > > Is the text function the thing I should be using? As the field is > typed as a boolean... > > Best, Robin > > -----Original message----- > *From:* Jeremy Nix <[hidden email]> > *Sent:* Wed 07-07-2010 14:15 > *To:* [hidden email]; > *Subject:* [ops-users] Re: Question on Xpath Count? > > What exactly are you trying to count? If you're looking to count the > element "<a>" then your syntax appears to be working as desired. > If you > wanting to count the number of <b> elements with a <c> element of > true, > then the syntax would be: > > count(./a/b[@attr='something' and c='true']) > > If you're trying to count the number of <c> elements that are > true, you > could use this: > > count(./a/b[@attr='something']//c[text()='true']) > > > ------------------------------------------------------------------------ > Jeremy Nix > Senior Application Developer > Cincinnati Children's Hospital Medical Center > > On 07/07/2010 07:25 AM, Robin Diederen wrote: > > > > Hello all, > > > > On my Xform I have the following construction: > > > > <xforms:output value="count(.[/a/b[@attr='something']//c = > 'true'])"/> > > > > And in my instance document, I have: > > > > <ser:ciz xmlns="http://www.workflow4people.org/services" > > xmlns:ser="http://www.workflow4people.org/services"> > > > > <a> > > <b attr="something"> > > <c xsi:type="xs:boolean">false</c> > > > > <d>Me</d> > > </b> > > > > <b attr="something"> > > <c xsi:type="xs:boolean">false</c> > > <d>You</d> > > </b> > > </a> > > > > This count always returns 1 or zero. If no c-elements are set to > true, > > a 0 is returned. If there's one ore more set to true, a 1 is > returned, > > always. > > > > What am I doing wrong? > > > > Best, Robin > > > -- 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 OW2 mailing lists service home page: http://www.ow2.org/wws |
Free forum by Nabble | Edit this page |