test for empty node

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

test for empty node

dr.cw.ray
I was trying to check if a <text/> element was holding any text value
(e.g. <text>something</text> vs. <text></text> or <text/> )
I tried:

<xf:setvalue ref="//text"  value="if( . ='', 'empty', . )"/>

and also

<xf:setvalue ref="//text2"
                value="if( //text='', 'empty', 'notEmpty')"/>


At any rate, it's not working. I did some searches but couldn't find
anything.
How do I test for an empty value in a node?

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

Re: test for empty node

Aaron Reed
Try this -> http://bytes.com/forum/thread88452.html

Let me know if it doesn't work.

--Aaron

[hidden email] wrote:

> I was trying to check if a <text/> element was holding any text value
> (e.g. <text>something</text> vs. <text></text> or <text/> )
> I tried:
>
> <xf:setvalue ref="//text"  value="if( . ='', 'empty', . )"/>
>
> and also
>
> <xf:setvalue ref="//text2"
>                 value="if( //text='', 'empty', 'notEmpty')"/>
>
>
> At any rate, it's not working. I did some searches but couldn't find
> anything.
> How do I test for an empty value in a node?
>
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms
Reply | Threaded
Open this post in threaded view
|

Re: test for empty node

dr.cw.ray
On Jul 22, 1:47 am, Aaron Reed <[hidden email]> wrote:

> Try this ->http://bytes.com/forum/thread88452.html
>
> Let me know if it doesn't work.
>
> --Aaron
>
> [hidden email] wrote:
> > I was trying to check if a <text/> element was holding any text value
> > (e.g. <text>something</text> vs. <text></text> or <text/> )
> > I tried:
>
> > <xf:setvalue ref="//text"  value="if( . ='', 'empty', . )"/>
>
> > and also
>
> > <xf:setvalue ref="//text2"
> >                 value="if( //text='', 'empty', 'notEmpty')"/>
>
> > At any rate, it's not working. I did some searches but couldn't find
> > anything.
> > How do I test for an empty value in a node?

Somebody shoot me.  I copied my setvalue over from an action element,
so of course, my xforms-event was missing.   Geesh.  I wasted how many
hours?  Am I the only one who does this kind of stuff?  Somebody speak
comfort to me. :)

So the results are
instance..
   <ztext/>
  <ztext2/>
 <xf:setvalue ref="//ztext2"
         value="if( //ztext='', 'empty', 'notEmpty')"/>
works just fine.

However, since Aaron was nice enough to respond, I checked out the
above link. The  results  were interesting.  If the ztext loads as
empty, then testing with
 //ztext[not(node())]
or
 //ztext[not(text())]
will show it as empty. However, after a user inputs a value into an
input box, then deletes it, the expression still returns "notEmpty".
Since xpath is my weakness, it's probably not a bug, just me, but
here's the code if someone wants to take a look (working and non-
working examples).

Works:
<?xml version="1.0"?>
<h:html
 xmlns:h="http://www.w3.org/1999/xhtml"
 xmlns:ev="http://www.w3.org/2001/xml-events"
 xmlns:xf="http://www.w3.org/2002/xforms"
 xmlns:xs="http://www.w3.org/2001/XMLSchema">

<h:head>
   <h:title> Test Empty </h:title>
   <xf:model id="mm">
      <xf:instance>
         <data xmlns="">
            <ztext></ztext>
            <ztext2/>
         </data>
      </xf:instance>
   </xf:model>
</h:head>
<h:body>
   <!--==============================-->
      ztext<xf:input ref="//ztext"/>
      <xf:trigger><xf:label>test</xf:label>
         <xf:setvalue ev:event="DOMActivate" ref="//ztext2"
value="if( //ztext='', 'empty', 'notEmpty')"/>
      </xf:trigger>
      <xf:output ref="//ztext"/>
      <xf:output ref="//ztext2"/>
</h:body>
</h:html>

NON_WORKING with not(node()) and not(text())
<?xml version="1.0"?>
<h:html
 xmlns:h="http://www.w3.org/1999/xhtml"
 xmlns:ev="http://www.w3.org/2001/xml-events"
 xmlns:xf="http://www.w3.org/2002/xforms"
 xmlns:xs="http://www.w3.org/2001/XMLSchema">

<h:head>
   <h:title> Template </h:title>
   <xf:model id="mm">
      <xf:instance>
         <data xmlns="">
            <ztext></ztext>
            <ztext2/>
            <zbool/>
         </data>
      </xf:instance>
      <xf:bind nodeset="//zbool" type="xs:boolean"/>
   </xf:model>
</h:head>
<h:body>
   <!--==============================-->
      ztext<xf:input ref="//ztext"/>
      <xf:trigger><xf:label>test</xf:label>
         <xf:setvalue ev:event="DOMActivate" ref="//ztext2"
            value="if( //zbool=//ztext[not(node())], 'empty',
'notEmpty')"/>
      </xf:trigger>
      <xf:output ref="//ztext"/>
      <xf:output ref="//ztext2"/>
</h:body>
</h: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: test for empty node

Aaron Reed
Looks like you are testing for not node instead of not text though I
don't know if it matters in the end.  You'd have to look to see exactly
how they work, but it probably has something to do with an inner text
node.  The node that you are evaluating probably doesn't have an inner
text node child initially but does after it gets a value and it is
likely still there even after it no longer has a value.  Which,
depending how those functions work, could be your issue.

--Aaron

[hidden email] wrote:

> On Jul 22, 1:47 am, Aaron Reed <[hidden email]> wrote:
>> Try this ->http://bytes.com/forum/thread88452.html
>>
>> Let me know if it doesn't work.
>>
>> --Aaron
>>
>> [hidden email] wrote:
>>> I was trying to check if a <text/> element was holding any text value
>>> (e.g. <text>something</text> vs. <text></text> or <text/> )
>>> I tried:
>>> <xf:setvalue ref="//text"  value="if( . ='', 'empty', . )"/>
>>> and also
>>> <xf:setvalue ref="//text2"
>>>                 value="if( //text='', 'empty', 'notEmpty')"/>
>>> At any rate, it's not working. I did some searches but couldn't find
>>> anything.
>>> How do I test for an empty value in a node?
>
> Somebody shoot me.  I copied my setvalue over from an action element,
> so of course, my xforms-event was missing.   Geesh.  I wasted how many
> hours?  Am I the only one who does this kind of stuff?  Somebody speak
> comfort to me. :)
>
> So the results are
> instance..
>    <ztext/>
>   <ztext2/>
>  <xf:setvalue ref="//ztext2"
>          value="if( //ztext='', 'empty', 'notEmpty')"/>
> works just fine.
>
> However, since Aaron was nice enough to respond, I checked out the
> above link. The  results  were interesting.  If the ztext loads as
> empty, then testing with
>  //ztext[not(node())]
> or
>  //ztext[not(text())]
> will show it as empty. However, after a user inputs a value into an
> input box, then deletes it, the expression still returns "notEmpty".
> Since xpath is my weakness, it's probably not a bug, just me, but
> here's the code if someone wants to take a look (working and non-
> working examples).
>
> Works:
> <?xml version="1.0"?>
> <h:html
>  xmlns:h="http://www.w3.org/1999/xhtml"
>  xmlns:ev="http://www.w3.org/2001/xml-events"
>  xmlns:xf="http://www.w3.org/2002/xforms"
>  xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> <h:head>
>    <h:title> Test Empty </h:title>
>    <xf:model id="mm">
>       <xf:instance>
>          <data xmlns="">
>             <ztext></ztext>
>             <ztext2/>
>          </data>
>       </xf:instance>
>    </xf:model>
> </h:head>
> <h:body>
>    <!--==============================-->
>       ztext<xf:input ref="//ztext"/>
>       <xf:trigger><xf:label>test</xf:label>
>          <xf:setvalue ev:event="DOMActivate" ref="//ztext2"
> value="if( //ztext='', 'empty', 'notEmpty')"/>
>       </xf:trigger>
>       <xf:output ref="//ztext"/>
>       <xf:output ref="//ztext2"/>
> </h:body>
> </h:html>
>
> NON_WORKING with not(node()) and not(text())
> <?xml version="1.0"?>
> <h:html
>  xmlns:h="http://www.w3.org/1999/xhtml"
>  xmlns:ev="http://www.w3.org/2001/xml-events"
>  xmlns:xf="http://www.w3.org/2002/xforms"
>  xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> <h:head>
>    <h:title> Template </h:title>
>    <xf:model id="mm">
>       <xf:instance>
>          <data xmlns="">
>             <ztext></ztext>
>             <ztext2/>
>             <zbool/>
>          </data>
>       </xf:instance>
>       <xf:bind nodeset="//zbool" type="xs:boolean"/>
>    </xf:model>
> </h:head>
> <h:body>
>    <!--==============================-->
>       ztext<xf:input ref="//ztext"/>
>       <xf:trigger><xf:label>test</xf:label>
>          <xf:setvalue ev:event="DOMActivate" ref="//ztext2"
>             value="if( //zbool=//ztext[not(node())], 'empty',
> 'notEmpty')"/>
>       </xf:trigger>
>       <xf:output ref="//ztext"/>
>       <xf:output ref="//ztext2"/>
> </h:body>
> </h: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: test for empty node

Klotz, Leigh
In reply to this post by dr.cw.ray
I couldn't figure out why the original didn't work either.  Are you
saying it works now that you have the ev:event?

-----Original Message-----
From: dev-tech-xforms-bounces+leigh.klotz=[hidden email]
[mailto:dev-tech-xforms-bounces+leigh.klotz=[hidden email]]
On Behalf Of [hidden email]
Sent: Monday, July 21, 2008 12:41 PM
To: [hidden email]
Subject: Re: test for empty node

On Jul 22, 1:47 am, Aaron Reed <[hidden email]> wrote:

> Try this ->http://bytes.com/forum/thread88452.html
>
> Let me know if it doesn't work.
>
> --Aaron
>
> [hidden email] wrote:
> > I was trying to check if a <text/> element was holding any text
> > value (e.g. <text>something</text> vs. <text></text> or <text/> ) I
> > tried:
>
> > <xf:setvalue ref="//text"  value="if( . ='', 'empty', . )"/>
>
> > and also
>
> > <xf:setvalue ref="//text2"
> >                 value="if( //text='', 'empty', 'notEmpty')"/>
>
> > At any rate, it's not working. I did some searches but couldn't find

> > anything.
> > How do I test for an empty value in a node?

Somebody shoot me.  I copied my setvalue over from an action element,
so of course, my xforms-event was missing.   Geesh.  I wasted how many
hours?  Am I the only one who does this kind of stuff?  Somebody speak
comfort to me. :)

So the results are
instance..
   <ztext/>
  <ztext2/>
 <xf:setvalue ref="//ztext2"
         value="if( //ztext='', 'empty', 'notEmpty')"/> works just fine.

However, since Aaron was nice enough to respond, I checked out the above
link. The  results  were interesting.  If the ztext loads as empty, then
testing with  //ztext[not(node())] or  //ztext[not(text())] will show it
as empty. However, after a user inputs a value into an input box, then
deletes it, the expression still returns "notEmpty".
Since xpath is my weakness, it's probably not a bug, just me, but here's
the code if someone wants to take a look (working and non- working
examples).

Works:
<?xml version="1.0"?>
<h:html
 xmlns:h="http://www.w3.org/1999/xhtml"
 xmlns:ev="http://www.w3.org/2001/xml-events"
 xmlns:xf="http://www.w3.org/2002/xforms"
 xmlns:xs="http://www.w3.org/2001/XMLSchema">

<h:head>
   <h:title> Test Empty </h:title>
   <xf:model id="mm">
      <xf:instance>
         <data xmlns="">
            <ztext></ztext>
            <ztext2/>
         </data>
      </xf:instance>
   </xf:model>
</h:head>
<h:body>
   <!--==============================-->
      ztext<xf:input ref="//ztext"/>
      <xf:trigger><xf:label>test</xf:label>
         <xf:setvalue ev:event="DOMActivate" ref="//ztext2"
value="if( //ztext='', 'empty', 'notEmpty')"/>
      </xf:trigger>
      <xf:output ref="//ztext"/>
      <xf:output ref="//ztext2"/>
</h:body>
</h:html>

NON_WORKING with not(node()) and not(text()) <?xml version="1.0"?>
<h:html  xmlns:h="http://www.w3.org/1999/xhtml"
 xmlns:ev="http://www.w3.org/2001/xml-events"
 xmlns:xf="http://www.w3.org/2002/xforms"
 xmlns:xs="http://www.w3.org/2001/XMLSchema">

<h:head>
   <h:title> Template </h:title>
   <xf:model id="mm">
      <xf:instance>
         <data xmlns="">
            <ztext></ztext>
            <ztext2/>
            <zbool/>
         </data>
      </xf:instance>
      <xf:bind nodeset="//zbool" type="xs:boolean"/>
   </xf:model>
</h:head>
<h:body>
   <!--==============================-->
      ztext<xf:input ref="//ztext"/>
      <xf:trigger><xf:label>test</xf:label>
         <xf:setvalue ev:event="DOMActivate" ref="//ztext2"
            value="if( //zbool=//ztext[not(node())], 'empty',
'notEmpty')"/>
      </xf:trigger>
      <xf:output ref="//ztext"/>
      <xf:output ref="//ztext2"/>
</h:body>
</h: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: test for empty node

dr.cw.ray
In reply to this post by dr.cw.ray
On Jul 22, 6:19 am, "Klotz, Leigh" <[hidden email]> wrote:

> I couldn't figure out why the original didn't work either.  Are you
> saying it works now that you have the ev:event?
>
> -----Original Message-----
> From: dev-tech-xforms-bounces+leigh.klotz=[hidden email]
>
> [mailto:dev-tech-xforms-bounces+leigh.klotz=[hidden email]]
> On Behalf Of [hidden email]
> Sent: Monday, July 21, 2008 12:41 PM
> To: [hidden email]
> Subject: Re: test for empty node
>
> On Jul 22, 1:47 am, Aaron Reed <[hidden email]> wrote:
> > Try this ->http://bytes.com/forum/thread88452.html
>
> > Let me know if it doesn't work.
>
> > --Aaron
>
> > [hidden email] wrote:
> > > I was trying to check if a <text/> element was holding any text
> > > value (e.g. <text>something</text> vs. <text></text> or <text/> ) I
> > > tried:
>
> > > <xf:setvalue ref="//text"  value="if( . ='', 'empty', . )"/>
>
> > > and also
>
> > > <xf:setvalue ref="//text2"
> > >                 value="if( //text='', 'empty', 'notEmpty')"/>
>
> > > At any rate, it's not working. I did some searches but couldn't find
>
> > > anything.
> > > How do I test for an empty value in a node?
>
> Somebody shoot me.  I copied my setvalue over from an action element,
> so of course, my xforms-event was missing.   Geesh.  I wasted how many
> hours?  Am I the only one who does this kind of stuff?  Somebody speak
> comfort to me. :)
>
> So the results are
> instance..
>    <ztext/>
>   <ztext2/>
>  <xf:setvalue ref="//ztext2"
>          value="if( //ztext='', 'empty', 'notEmpty')"/> works just fine.
>
> However, since Aaron was nice enough to respond, I checked out the above
> link. The  results  were interesting.  If the ztext loads as empty, then
> testing with  //ztext[not(node())] or  //ztext[not(text())] will show it
> as empty. However, after a user inputs a value into an input box, then
> deletes it, the expression still returns "notEmpty".
> Since xpath is my weakness, it's probably not a bug, just me, but here's
> the code if someone wants to take a look (working and non- working
> examples).
>
> Works:
> <?xml version="1.0"?>
> <h:html
>  xmlns:h="http://www.w3.org/1999/xhtml"
>  xmlns:ev="http://www.w3.org/2001/xml-events"
>  xmlns:xf="http://www.w3.org/2002/xforms"
>  xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> <h:head>
>    <h:title> Test Empty </h:title>
>    <xf:model id="mm">
>       <xf:instance>
>          <data xmlns="">
>             <ztext></ztext>
>             <ztext2/>
>          </data>
>       </xf:instance>
>    </xf:model>
> </h:head>
> <h:body>
>    <!--==============================-->
>       ztext<xf:input ref="//ztext"/>
>       <xf:trigger><xf:label>test</xf:label>
>          <xf:setvalue ev:event="DOMActivate" ref="//ztext2"
> value="if( //ztext='', 'empty', 'notEmpty')"/>
>       </xf:trigger>
>       <xf:output ref="//ztext"/>
>       <xf:output ref="//ztext2"/>
> </h:body>
> </h:html>
>
> NON_WORKING with not(node()) and not(text()) <?xml version="1.0"?>
> <h:html  xmlns:h="http://www.w3.org/1999/xhtml"
>  xmlns:ev="http://www.w3.org/2001/xml-events"
>  xmlns:xf="http://www.w3.org/2002/xforms"
>  xmlns:xs="http://www.w3.org/2001/XMLSchema">
>
> <h:head>
>    <h:title> Template </h:title>
>    <xf:model id="mm">
>       <xf:instance>
>          <data xmlns="">
>             <ztext></ztext>
>             <ztext2/>
>             <zbool/>
>          </data>
>       </xf:instance>
>       <xf:bind nodeset="//zbool" type="xs:boolean"/>
>    </xf:model>
> </h:head>
> <h:body>
>    <!--==============================-->
>       ztext<xf:input ref="//ztext"/>
>       <xf:trigger><xf:label>test</xf:label>
>          <xf:setvalue ev:event="DOMActivate" ref="//ztext2"
>             value="if( //zbool=//ztext[not(node())], 'empty',
> 'notEmpty')"/>
>       </xf:trigger>
>       <xf:output ref="//ztext"/>
>       <xf:output ref="//ztext2"/>
> </h:body>
> </h:html>
> _______________________________________________
> dev-tech-xforms mailing list
> [hidden email]://lists.mozilla.org/listinfo/dev-tech-xforms

Yes, Leigh, you're right. The original works just fine now, and that's
why I was so confused before. So really, there's no problems here.
_______________________________________________
dev-tech-xforms mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-xforms