Andy Bierman writes:
>I think text() and node() are just filter tests.
>
>  /foo/*[text()] would return all the child nodes of /foo that are leaf or
>leaf-list
>
>text() returns a boolean (0 or 1).  Do not use it for value testing:
>
>  /foo/*[text() =3D 'fred']  // wrong!
>
>  /foo/*[. =3D 'fred']  // correct

I haven't looked at the spec, but this isn't true for libxml2/libxslt/libslax:

(sdb) n
4: var $foo := <top> { <one> "one"; <two> "two"; }
(sdb) n
2: main <foo> { }
(sdb) p $foo
[node-set] (1) rtf-doc
<top>
  <one>one</one>
  <two>two</two>
</top>


(sdb) p $foo/*
[node-set] (1)
<top>
  <one>one</one>
  <two>two</two>
</top>

Outside predicates, it's a node test, matching text nodes:

(sdb) p $foo/*/text()
[node-set] (0)

(sdb) p $foo/*/*/text()
[node-set] (2)
one
two

But inside predicates is does return the text, probably like string():

(sdb) p $foo/*/*
[node-set] (2)
<one>one</one>
<two>two</two>

(sdb) p $foo/*[text() == 'one']
[node-set] (0)

(sdb) p $foo/*/*[text() == 'one']
[node-set] (1)
<one>one</one>

It could be just a bug in libxml2;  I'll take a look.

Thanks,
 Phil

P.s.: the command line I used was:

   slaxproc -d -m 'main <foo> { }' -E -m 'var $foo := <top> { <one> "one"; 
<two> "two"; }'

The ":=" operator turns RTFs into node-sets (via calling node-set()).

_______________________________________________
netmod mailing list
[email protected]
https://www.ietf.org/mailman/listinfo/netmod

Reply via email to