[phpXML] Re: [phpXML] Re: [phpXML] [xpath.class.php] Question (stupid one ?)

2001-09-30 Thread bs_php

Hi Luc, 

my answer will be surprising: "Everything is OK".
The problem is in the code of M.Mehl you  use to do the query. 
It's missing quotes !:
Sample:
   //person/*[contains(., 'Jos')]/..( Not//person/*[contains(., Jos)]/.. )

Correct line 134 (+/-)
 $government = $xml->evaluate( "//person/*[contains(., $term)]/..");
to
 $government = $xml->evaluate( "//person/*[contains(., '$term')]/..");

Otherwise XPath will asume it's a function call instead of a string
and will try to evaluate it. 

-- 
Sam Blum <[EMAIL PROTECTED]>

===
For the most recent version of phpxml, V1.N.X, and an archive of this list
visit:  http://www.sourceforge.net/projects/phpxmldb

--
This message has been sent through the  user discussion list. To unsubscribe, 
please visit https:[EMAIL PROTECTED]/

___
Phpxmldb-phpxml-arc mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/phpxmldb-phpxml-arc



[phpXML] Re: [phpXML] [xpath.class.php] Question (stupid one ?)

2001-09-29 Thread nigelswinson

> I'm still fighting with xpath.class.php
>
> I don't buy the fact the problems I have with xpath.class.php are related
> to my ISP because xml.php 1N6 works like a charm) and I use it a lot.

Yeah, I'm not that happy with it as the reason either...

> So I'd to have a detailed explanation of the meaning of the following
error :
> phpXML error: While parsing an XPath expression there was an error in the
> predicate "Gerhard", because it was the null string. If you wish to seach
> for the empty string, you must use ''.
>
>
> Context
> 
> xpath.class.php
>
> Line 1996
>  if (ereg('^\w*$', $predicate)) {
>// Display an error message.
>$this->_displayError("While parsing an XPath expression ".
>  "there was an error in the predicate \"$predicate\", ".
>  "because it was the null string.  If you wish to seach ".
>  "for the empty string, you must use ''.");
>return FALSE;
>  }
>
> The error occurs when I try to use xpath.class.php  with government
example
> in this case searching for Gerhard::
>
> phpXML error: While parsing an XPath expression there was an error in the
> predicate "Gerhard", because it was the null string. If you wish to seach
> for the empty string, you must use ''.
>
> Question
> ===
> How can the string "Gerhard" be a "null string" ???

I only know how to use perl regexes, and have still not found a decent POSIX
reference despite 1 hour of searching the other day.  Run the following
script:

\n";
echo 'result from ereg (using POSIX regexes) is:'.(ereg('^\w$',"Gerhard") ?
"true" : "false")."\n";
echo 'result from preg_match (using PERL regexes)
is:'.(preg_match("/^\s*$/", "Gerhard") ? "true" : "false")."\n";

echo "With ''\n";
echo 'result from ereg (using POSIX regexes) is:'.(ereg('^\w$',"") ? "true"
: "false")."\n";
echo 'result from preg_match (using PERL regexes)
is:'.(preg_match("/^\s*$/", "") ? "true" : "false")."\n";

?>

I get an output of:

With 'Gehard'
result from ereg (using POSIX regexes) is:false
result from preg_match (using PERL regexes) is:false
With ''
result from ereg (using POSIX regexes) is:false
result from preg_match (using PERL regexes) is:true

Which shows to me that the regex is wrong.  So change this line:
 if (ereg('^\w*$', $predicate)) {
to:
if (preg_match("/^\s*$/, $predicate)) {

And let us all know if it works.

Nigel


--
This message has been sent through the  user discussion list. To unsubscribe, 
please visit https:[EMAIL PROTECTED]/

___
Phpxmldb-phpxml-arc mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/phpxmldb-phpxml-arc



[phpXML] [xpath.class.php] Question (stupid one ?)

2001-09-29 Thread luc

Hello,

I'm still fighting with xpath.class.php

I don't buy the fact the problems I have with xpath.class.php are related 
to my ISP because xml.php 1N6 works like a charm) and I use it a lot.

So I'd to have a detailed explanation of the meaning of the following error :
phpXML error: While parsing an XPath expression there was an error in the 
predicate "Gerhard", because it was the null string. If you wish to seach 
for the empty string, you must use ''.


Context

xpath.class.php

Line 1996
 if (ereg('^\w*$', $predicate)) {
   // Display an error message.
   $this->_displayError("While parsing an XPath expression ".
 "there was an error in the predicate \"$predicate\", ".
 "because it was the null string.  If you wish to seach ".
 "for the empty string, you must use ''.");
   return FALSE;
 }

The error occurs when I try to use xpath.class.php  with government example 
in this case searching for Gerhard::

phpXML error: While parsing an XPath expression there was an error in the 
predicate "Gerhard", because it was the null string. If you wish to seach 
for the empty string, you must use ''.

Question
===
How can the string "Gerhard" be a "null string" ???

Luc

--
This message has been sent through the  user discussion list. To unsubscribe, 
please visit https:[EMAIL PROTECTED]/

___
Phpxmldb-phpxml-arc mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/phpxmldb-phpxml-arc