Trying to use predicate to inhibit output

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

Trying to use predicate to inhibit output

Gary-138

I need to inhibit the output of some instance data, for example when a
boolean value is false. A predicate on the ref attribute should
accomplish that. I tried that approach with the following sample. I
was not able to inhibit output based on a predicate expression.

The results:
ref="endofline[false()]" -- no output
ref="endofline[true()]" --- always output
ref="endofline[boolean(true())]" -- always output
ref="endofline[boolean(.)]" -- always output

I repeated the test using the value attribute vs ref, with the same
results, except for value="endofline[false()]" where there is always
output.

I believe this is a bug. Has it been reported? I would like to vote
for it.

Thanks
Gary

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:ev="http://www.w3.org/2001/xml-events"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<meta name="author" content="gary" />
<meta name="Organization" content="none" />
<meta name="DescriptionVersion" content="1" />
<meta name="Generator" content="Descriptive Data Capture" />
<title>Inhibit endofline via a predicate expression</title>
<xf:model>
  <xf:instance xmlns="">

    <Main>
      <endofline>false</endofline>
    </Main>
  </xf:instance>
  <xf:bind nodeset="endofline" type="xs:boolean" />
</xf:model>
</head>
<body>
<fieldset><legend>ref</legend>
<fieldset><legend> ref="endofline[false()]"</legend>

<xf:output ref="endofline[false()]"><xf:label>End of Line is </
xf:label></xf:output>
</fieldset>
<fieldset><legend> ref="endofline[true()]"</legend>
<xf:output ref="endofline[true()]"><xf:label>End of Line is </
xf:label></xf:output>
</fieldset>
<fieldset><legend> ref="endofline[boolean(true())]"</legend>
<xf:output ref="endofline[boolean(true())]"><xf:label>End of Line is </
xf:label></xf:output>
</fieldset>
<fieldset><legend> ref="endofline[boolean(.)]"</legend>

<xf:output ref="endofline[boolean(.)]"><xf:label>End of Line is </
xf:label></xf:output>
</fieldset>
</fieldset>

<fieldset><legend>value</legend>
<fieldset><legend> value="endofline[false()]"</legend>
<xf:output value="endofline[false()]"><xf:label>End of Line is </
xf:label></xf:output>
</fieldset>
<fieldset><legend> value="endofline[true()]"</legend>
<xf:output value="endofline[true()]"><xf:label>End of Line is </
xf:label></xf:output>

</fieldset>
<fieldset><legend> value="endofline[boolean(true())]"</legend>
<xf:output value="endofline[boolean(true())]"><xf:label>End of Line is
</xf:label></xf:output>
</fieldset>
<fieldset><legend> value="endofline[boolean(.)]"</legend>
<xf:output value="endofline[boolean(.)]"><xf:label>End of Line is </
xf:label></xf:output>
</fieldset>
</fieldset>


<xf:input ref="endofline">

<xf:label>endofline</xf:label></xf:input>

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

Re: Trying to use predicate to inhibit output

Aaron Reed
@ref binds to an instance node.  I don't know what "endofline[false()]"
would evaluate to in xpath since false() returns a boolean, not an
integer.  So I don't know that endofline[true] would necessarily be the
same as endofline[1], for example.

You could use bind with @relevant, of course, to show or hide controls
bound to the nodes referenced by the bind element.  That would be the
'recommended' xforms way.  You could also store visibility on the
instance node itself, I guess.  For example, <instance><root><foo
visible="true"/></root></instance> and then bind the control to
/root/foo[@visibility="true"] which seems to be more inline with what
you were trying to do.

Hope that this helps,
--Aaron


Gary wrote:

> I need to inhibit the output of some instance data, for example when a
> boolean value is false. A predicate on the ref attribute should
> accomplish that. I tried that approach with the following sample. I
> was not able to inhibit output based on a predicate expression.
>
> The results:
> ref="endofline[false()]" -- no output
> ref="endofline[true()]" --- always output
> ref="endofline[boolean(true())]" -- always output
> ref="endofline[boolean(.)]" -- always output
>
> I repeated the test using the value attribute vs ref, with the same
> results, except for value="endofline[false()]" where there is always
> output.
>
> I believe this is a bug. Has it been reported? I would like to vote
> for it.
>
> Thanks
> Gary
>
> <?xml version="1.0" encoding="iso-8859-1"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
> www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html
> xmlns="http://www.w3.org/1999/xhtml"
> xmlns:xf="http://www.w3.org/2002/xforms"
> xmlns:ev="http://www.w3.org/2001/xml-events"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <head>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1" />
> <meta name="author" content="gary" />
> <meta name="Organization" content="none" />
> <meta name="DescriptionVersion" content="1" />
> <meta name="Generator" content="Descriptive Data Capture" />
> <title>Inhibit endofline via a predicate expression</title>
> <xf:model>
>   <xf:instance xmlns="">
>
>     <Main>
>       <endofline>false</endofline>
>     </Main>
>   </xf:instance>
>   <xf:bind nodeset="endofline" type="xs:boolean" />
> </xf:model>
> </head>
> <body>
> <fieldset><legend>ref</legend>
> <fieldset><legend> ref="endofline[false()]"</legend>
>
> <xf:output ref="endofline[false()]"><xf:label>End of Line is </
> xf:label></xf:output>
> </fieldset>
> <fieldset><legend> ref="endofline[true()]"</legend>
> <xf:output ref="endofline[true()]"><xf:label>End of Line is </
> xf:label></xf:output>
> </fieldset>
> <fieldset><legend> ref="endofline[boolean(true())]"</legend>
> <xf:output ref="endofline[boolean(true())]"><xf:label>End of Line is </
> xf:label></xf:output>
> </fieldset>
> <fieldset><legend> ref="endofline[boolean(.)]"</legend>
>
> <xf:output ref="endofline[boolean(.)]"><xf:label>End of Line is </
> xf:label></xf:output>
> </fieldset>
> </fieldset>
>
> <fieldset><legend>value</legend>
> <fieldset><legend> value="endofline[false()]"</legend>
> <xf:output value="endofline[false()]"><xf:label>End of Line is </
> xf:label></xf:output>
> </fieldset>
> <fieldset><legend> value="endofline[true()]"</legend>
> <xf:output value="endofline[true()]"><xf:label>End of Line is </
> xf:label></xf:output>
>
> </fieldset>
> <fieldset><legend> value="endofline[boolean(true())]"</legend>
> <xf:output value="endofline[boolean(true())]"><xf:label>End of Line is
> </xf:label></xf:output>
> </fieldset>
> <fieldset><legend> value="endofline[boolean(.)]"</legend>
> <xf:output value="endofline[boolean(.)]"><xf:label>End of Line is </
> xf:label></xf:output>
> </fieldset>
> </fieldset>
>
>
> <xf:input ref="endofline">
>
> <xf:label>endofline</xf:label></xf:input>
>
> </body>
> </html>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

RE: Trying to use predicate to inhibit output

Klotz, Leigh
endofline[false()] ought to work as Xpath predicates can be numeric 1-based indices or boolean expressions.
It's just that we don't often see them with such a literal boolean.

One issue you might be having though, is that dot is not allowed in Xpath 1.0 inside predicates.
It doesn't seem to have been a deliberate omission, but there you go.

Try self::node() instead of dot inside the predicate and see if that works for you:

ref="endofline[boolean(self::node())]

Leigh.

-----Original Message-----
From: dev-tech-xforms-bounces+leigh.klotz=[hidden email] [mailto:dev-tech-xforms-bounces+leigh.klotz=[hidden email]] On Behalf Of Aaron Reed
Sent: Tuesday, June 02, 2009 10:01 AM
To: [hidden email]
Subject: Re: Trying to use predicate to inhibit output

@ref binds to an instance node.  I don't know what "endofline[false()]"
would evaluate to in xpath since false() returns a boolean, not an integer.  So I don't know that endofline[true] would necessarily be the same as endofline[1], for example.

You could use bind with @relevant, of course, to show or hide controls bound to the nodes referenced by the bind element.  That would be the 'recommended' xforms way.  You could also store visibility on the instance node itself, I guess.  For example, <instance><root><foo visible="true"/></root></instance> and then bind the control to /root/foo[@visibility="true"] which seems to be more inline with what you were trying to do.

Hope that this helps,
--Aaron


Gary wrote:

> I need to inhibit the output of some instance data, for example when a
> boolean value is false. A predicate on the ref attribute should
> accomplish that. I tried that approach with the following sample. I
> was not able to inhibit output based on a predicate expression.
>
> The results:
> ref="endofline[false()]" -- no output
> ref="endofline[true()]" --- always output
> ref="endofline[boolean(true())]" -- always output
> ref="endofline[boolean(.)]" -- always output
>
> I repeated the test using the value attribute vs ref, with the same
> results, except for value="endofline[false()]" where there is always
> output.
>
> I believe this is a bug. Has it been reported? I would like to vote
> for it.
>
> Thanks
> Gary
>
> <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC
> "-//W3C//DTD XHTML 1.0 Strict//EN" "http://
> www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
> <html
> xmlns="http://www.w3.org/1999/xhtml"
> xmlns:xf="http://www.w3.org/2002/xforms"
> xmlns:ev="http://www.w3.org/2001/xml-events"
> xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <head>
> <meta http-equiv="Content-Type" content="text/html;
> charset=iso-8859-1" /> <meta name="author" content="gary" /> <meta
> name="Organization" content="none" /> <meta name="DescriptionVersion"
> content="1" /> <meta name="Generator" content="Descriptive Data
> Capture" /> <title>Inhibit endofline via a predicate
> expression</title> <xf:model>
>   <xf:instance xmlns="">
>
>     <Main>
>       <endofline>false</endofline>
>     </Main>
>   </xf:instance>
>   <xf:bind nodeset="endofline" type="xs:boolean" /> </xf:model>
> </head> <body> <fieldset><legend>ref</legend> <fieldset><legend>
> ref="endofline[false()]"</legend>
>
> <xf:output ref="endofline[false()]"><xf:label>End of Line is </
> xf:label></xf:output> </fieldset> <fieldset><legend>
> ref="endofline[true()]"</legend> <xf:output
> ref="endofline[true()]"><xf:label>End of Line is </
> xf:label></xf:output> </fieldset> <fieldset><legend>
> ref="endofline[boolean(true())]"</legend>
> <xf:output ref="endofline[boolean(true())]"><xf:label>End of Line is
> </ xf:label></xf:output> </fieldset> <fieldset><legend>
> ref="endofline[boolean(.)]"</legend>
>
> <xf:output ref="endofline[boolean(.)]"><xf:label>End of Line is </
> xf:label></xf:output> </fieldset> </fieldset>
>
> <fieldset><legend>value</legend>
> <fieldset><legend> value="endofline[false()]"</legend>
> <xf:output value="endofline[false()]"><xf:label>End of Line is </
> xf:label></xf:output> </fieldset> <fieldset><legend>
> value="endofline[true()]"</legend>
> <xf:output value="endofline[true()]"><xf:label>End of Line is </
> xf:label></xf:output>
>
> </fieldset>
> <fieldset><legend> value="endofline[boolean(true())]"</legend>
> <xf:output value="endofline[boolean(true())]"><xf:label>End of Line is
> </xf:label></xf:output> </fieldset> <fieldset><legend>
> value="endofline[boolean(.)]"</legend>
> <xf:output value="endofline[boolean(.)]"><xf:label>End of Line is </
> xf:label></xf:output> </fieldset> </fieldset>
>
>
> <xf:input ref="endofline">
>
> <xf:label>endofline</xf:label></xf:input>
>
> </body>
> </html>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: Trying to use predicate to inhibit output

Gary-138
In reply to this post by Aaron Reed
On Jun 2, 12:00 pm, Aaron Reed <[hidden email]> wrote:

> @ref binds to an instance node.  I don't know what "endofline[false()]"
> would evaluate to in xpath since false() returns a boolean, not an
> integer.  So I don't know that endofline[true] would necessarily be the
> same as endofline[1], for example.
>
> You could use bind with @relevant, of course, to show or hide controls
> bound to the nodes referenced by the bind element.  That would be the
> 'recommended' xforms way.  You could also store visibility on the
> instance node itself, I guess.  For example, <instance><root><foo
> visible="true"/></root></instance> and then bind the control to
> /root/foo[@visibility="true"] which seems to be more inline with what
> you were trying to do.
>
> Hope that this helps,
> --Aaron
>
<snip>
The way I came to understand predicates in XPath is that they come in
two types, integer and boolean. The boolean type is an acceptance
test. To answer your questions, ref should bind to the endofline
element of the first instance. The boolean should be used to accept or
reject the node.

If you load the example, it seems kind of blatant to me. The predicate
is used they way I expect, but the boolean() function does not seem to
returning what I expect. It should return true if the value of the
instance is 'true' or false otherwise.

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

Re: Trying to use predicate to inhibit output

Gary-138
In reply to this post by Aaron Reed
On Jun 2, 3:50 pm, "Klotz, Leigh" <[hidden email]> wrote:

> endofline[false()] ought to work as Xpath predicates can be numeric 1-based indices or boolean expressions.
> It's just that we don't often see them with such a literal boolean.
>
> One issue you might be having though, is that dot is not allowed in Xpath 1.0 inside predicates.
> It doesn't seem to have been a deliberate omission, but there you go.
>
> Try self::node() instead of dot inside the predicate and see if that works for you:
>
> ref="endofline[boolean(self::node())]
>
>
>
<snip>

Hi Leigh,
Thanks, I'll try it.
Still, '.' is documented as meaning the context element so
endofline[boolean(.)] is legal and if it doesn't work, it s/b fixed.

Ah June,
Gary
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms