Help please with this xpath statement not working as I'd hoped.

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

Help please with this xpath statement not working as I'd hoped.

michael-480
Hi,

I have an instance with these elements:
<contacts xmlns="">
     <contact key="">
           ...
           <address primary="true"> <!-- only one address can be
primary -->
               <code />
               <type />
               <label />
           </address>
     </contact>
</contacts>

In one contact I may have multiple addresses and I thought I could
pull out just the primary addresses with this statement:

<xf:setvalue ref="..." value="string(instance('contact_template')/
contact/address/[@primary=true()]/code)"/>

but it is decidedly not working. Should it work?

Many thanks.
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Help please with this xpath statement not working as I'd hoped.

Dion Sole
On Jul 1, 12:09 pm, michael <[hidden email]> wrote:
> <xf:setvalue ref="..." value="string(instance('contact_template')/
> contact/address/[@primary=true()]/code)"/>
The "/" between "address" and "[@primary...]" is wrong.
Also, you're comparing a string to a boolean (true in this case). But
that comparison would be true for any string except the empty string,
so for example, <address primary="false"/> would also work.

What you'd want would be something like the following:

<xf:setvalue ref="..." value="instance('contact_template')/contact/
address[@primary = 'true']/code"/>

or

<xf:setvalue ref="..." value="instance('contact_template')/contact/
address[boolean-from-string(@primary)]/code"/>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Help please with this xpath statement not working as I'd hoped.

RajaM-2
In reply to this post by michael-480

Hi Michael !!!
        In your setvalue no reference element mentioned (If u
assigning a value to element then should mention that ref should
not ... or empty). And u used the instance () but u not declared that
id in instance element. and in your setvalue [ string(instance
('contact_template')/contact/address/[@primary=true()]/code)"/  ] red
colored part is wrong you may mention like   string(instance
('contact_template')/contact/address[@primary='true']/code).

By
Rajamani Marimuthu
Junior Research Fellow-
Open Technology Centre


On Jul 1, 5:09 am, michael <[hidden email]> wrote:

> Hi,
>
> I have an instance with these elements:
> <contacts xmlns="">
>      <contact key="">
>            ...
>            <address primary="true"> <!-- only one address can be
> primary -->
>                <code />
>                <type />
>                <label />
>            </address>
>      </contact>
> </contacts>
>
> In one contact I may have multiple addresses and I thought I could
> pull out just the primary addresses with this statement:
>
> <xf:setvalue ref="..." value="string(instance('contact_template')/
> contact/address/[@primary=true()]/code)"/>
>
> but it is decidedly not working. Should it work?
>
> Many thanks.

_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Help please with this xpath statement not working as I'd hoped.

michael-480
Thanks for the suggestions. Strangely, I am still not getting this to
work using the suggestions.

Dion. I tried both with no success. Very strange.

Rajamani. I just used ... in place of the actual ref statement.
Instance is declared OK, I'm using the same reference in subsequent
setvalues with no problem.

This sort of thing is really hard to debug. Anyone know of a way to
debug?

Thanks again.
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Help please with this xpath statement not working as I'd hoped.

Aaron Reed
Hi Michael,

In situations where I want to see if I got an xpath expression correct,
I usually put in a xf:output with @value="my xpath expression" and
verify that I see the value that I think I should.

--Aaron

michael wrote:

> Thanks for the suggestions. Strangely, I am still not getting this to
> work using the suggestions.
>
> Dion. I tried both with no success. Very strange.
>
> Rajamani. I just used ... in place of the actual ref statement.
> Instance is declared OK, I'm using the same reference in subsequent
> setvalues with no problem.
>
> This sort of thing is really hard to debug. Anyone know of a way to
> debug?
>
> Thanks again.
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Help please with this xpath statement not working as I'd hoped.

Dion Sole
In reply to this post by michael-480
On Jul 2, 1:16 am, michael <[hidden email]> wrote:

> Thanks for the suggestions. Strangely, I am still not getting this to
> work using the suggestions.
>
> Dion. I tried both with no success. Very strange.
>
> Rajamani. I just used ... in place of the actual ref statement.
> Instance is declared OK, I'm using the same reference in subsequent
> setvalues with no problem.
>
> This sort of thing is really hard to debug. Anyone know of a way to
> debug?
>
> Thanks again.
If you don't have xforms buddy, install it from
http://beaufour.dk/index.php?sec=misc&pagename=xforms

Apart from that, I couldn't really say more without seeing the whole
form.
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms