Thread: Am I a doofus?
Brought to you by:
bs_php,
nigelswinson
From: Thomas P. N. <as...@mi...> - 2002-08-05 08:11:25
|
Hi list, I've noticed a lot of differences in migrating from v2.2 to v3.3. For instance, this was possible in v2.2: $myxpath = new xpath(); $myroot = $myxpath->appendChild("","superroot"); .. but not in v3.3. Furter, in v2.2 a query through evaluate() to an unique xpath would produce a string, whereas v3.3 produces an array There are workarounds for it, but none the less - I've had numerous encounters of the odd kind to which I can seem to find no obvious solution. Can anyone tell me if I can find documentation on the differences in implementation? Or, preferably; different examples on usage? I suspect being a doofus, but I'd really like to get this sorted out. Thank you for any help in advance. Sincerely, Thomas Pilgaard |
From: Nigel S. <nig...@us...> - 2002-08-06 00:22:50
|
> I've noticed a lot of differences in migrating from v2.2 to v3.3. :o( > For instance, this was possible in v2.2: > > $myxpath = new xpath(); > $myroot = $myxpath->appendChild("","superroot"); Ah... all the functions like importFromString() and appendChild() now take an xml string rather than just a node name, so you need to do: $myroot = $myxpath->appendChild("","<superroot/>"); However I just tried this and it didn't work, because the super root hadn't been setup, so this is a bug for which I thank you kindly for reporting :o) I've just implemented a change so that you can do this now. You'll find it in CVS if you can't wait for the next release, or you would like to do some testing :o) > .. but not in v3.3. Furter, in v2.2 a query through evaluate() to an > unique xpath would produce a string, whereas v3.3 produces an array > There are workarounds for it, but none the less - I've had numerous > encounters of the odd kind to which I can seem to find no obvious solution. In having a closer look at the XPath spec, the "top level" syntactical element is an "Expr", which.... http://www.w3.org/TR/xpath#section-Introduction "which has one of the following four basic types: a.. node-set (an unordered collection of nodes without duplicates) b.. boolean (true or false) c.. number (a floating-point number) d.. string (a sequence of UCS characters) " Clearly the intention wasn't to break anyone's code, but in order to support XPath properly (in it's recursive nature), you could now get a string, a number, a boolean or a node set (an array) as the result from match()/evaluate(). So if you have an xpath expression that is designed to "match" a node, then it really matches a node set that contains only one node, and hence it comes back to you in an array :o( You could always build a wrapper round match() that would convert an array with one element into just one string if that would make migration easier? > Can anyone tell me if I can find documentation on the differences in > implementation? Or, preferably; different examples on usage? I'll be more than happy to show you how to do what you need to do with version 3, sadly there is no definitive differences document. We worked fairly hard to minimise any public interface differences, as we know how distruptive they are to your code, and I was under the impression that the differences were slight, but then perhaps not... You could view the cvs history (which is fairly lenghty between 2.2 and 3.2), or do a diff between the .php files, but sadly nothing better than that is on offer. > I suspect being a doofus, but I'd really like to get this sorted out. Not a doofus at all :o) Let me/us know if you need anymore bug fixes or usage hints. Nigel |
From: Daniel L. <inf...@aj...> - 2002-08-06 13:57:51
|
Bonjour Nigel, Le mardi 6 ao=FBt 2002 =E0 02:19:52, vous =E9criviez : NS> $myroot =3D $myxpath->appendChild("","<superroot/>"); NS> However I just tried this and it didn't work, because the super root = hadn't NS> been setup, so this is a bug for which I thank you kindly for reporti= ng :o) NS> I've just implemented a change so that you can do this now. You'll f= ind it NS> in CVS if you can't wait for the next release, or you would like to d= o some NS> testing :o) I need the same feature so I try the CVS version 1.111, but without succe= ss. I try : $xml =3D new XPath(); $rootPath =3D $xml->appendChild( "", "<xml/>"); And I get : XPath error in XPath.class.php:1586 In importFromString(): XML error in given string on line 1 column 0. Reason:syntax error XPath error in XPath.class.php:5155 XPath error in XPath.class.php:1586. Message: In importFromString(): XML error in given string on line 1 column 0. Reason:syntax error --=20 Cordialement, Daniel mailto:inf...@aj... ---------- Support-Assistance PHP/MySql de =ABInternet Pour Tous=BB=20 http://www.i-p-t.com.fr/ :::XML/XSLT - Sablotron::: -- |
From: Thomas P. N. <as...@mi...> - 2002-08-07 07:39:59
|
Hi again, first off I want to thank you Nigel for the tremendous effort you put into this and I want you to know that it's greatly appreciated. Keep up the good work. Just to comment on Daniels problems: > XPath error in XPath.class.php:1586 In importFromString(): XML error > in given string on line 1 column 0. Reason:syntax error I get the same sort of error - that is varying 'XPath.class.php:####' errors followed by the 'line 1 column 0' hint. One further problem is in the code below. I know it's a bit lengthy - I hope you won't mind it. - Begin code ----- $myindex = new xpath(); $myindex->setSkipWhiteSpaces($onOff=TRUE); $myindex->setXmlOption('XML_OPTION_TARGET_ENCODING', 'UTF-8'); $myindex->importFromString("<searchindex/>"); $searchindex = $myindex->evaluate("searchindex"); foreach ($resultarray as $page => $pagename) { $xmlpage = $myindex->appendChild("searchindex","<$page/>"); foreach ($pagename as $itemkey => $itemvalue) { $myitem = $myindex->appendChild($xmlpage,"<item/>"); } } $myindex->exportToFile("../search_index.xml"); - End code ----- The problem is, that the child in the line '$myitem = $myindex->appendChild($xmlpage,"<item/>");' doesn't seem to work. Now, if placed outside the foreach loop it does work, which strikes me as odd. I've tried with manual as well as automatic reindexing, which doesn't seem to have an influence. I am presented with a blank screen when running the script - no error messages. Thank you very much for your time. Sincerely, Thomas |
From: Nigel S. <nig...@us...> - 2002-08-07 23:15:24
|
> first off I want to thank you Nigel for the tremendous effort you put into this and I want you to > know that it's greatly appreciated. Keep up the good work. Thanks for your kind comments. :o) > Just to comment on Daniels problems: > > > XPath error in XPath.class.php:1586 In importFromString(): XML error > > in given string on line 1 column 0. Reason:syntax error > > I get the same sort of error - that is varying 'XPath.class.php:####' errors followed by the 'line 1 > column 0' hint. Means you probably need to convert from "tag" to "<tag/>" in your calls to appendChild() etc? > One further problem is in the code below. I know it's a bit lengthy - I hope you won't mind it. > - Begin code ----- > $myindex = new xpath(); > $myindex->setSkipWhiteSpaces($onOff=TRUE); > $myindex->setXmlOption('XML_OPTION_TARGET_ENCODING', 'UTF-8'); > $myindex->importFromString("<searchindex/>"); > $searchindex = $myindex->evaluate("searchindex"); > foreach ($resultarray as $page => $pagename) > { > $xmlpage = $myindex->appendChild("searchindex","<$page/>"); > foreach ($pagename as $itemkey => $itemvalue) > { > $myitem = $myindex->appendChild($xmlpage,"<item/>"); > } > } > $myindex->exportToFile("../search_index.xml"); > - End code ----- > The problem is, that the child in the line '$myitem = $myindex->appendChild($xmlpage,"<item/>");' > doesn't seem to work. Now, if placed outside the foreach loop it does work, which strikes me as odd. > I've tried with manual as well as automatic reindexing, which doesn't seem to have an influence. > I am presented with a blank screen when running the script - no error messages. I'm not really sure what isn't working if anything, or what it's meant to do.... but $resultarray is never set, so it will never execute any of the inside of the foreach($resultarray as ....) loop, hence the above code isn't really going to do a whole lot... > Thank you very much for your time. No problem. It would be most helpful if you could attach .php/.xml/.html files that I can copy out and run and examine the output against your output to a) see if I get the same results and then b) work out if those results are "correct". Cheers, Nigel |
From: Nigel S. <nig...@us...> - 2002-08-08 12:58:19
|
> > I'm not really sure what isn't working if anything, or what it's meant to > > do.... but $resultarray is never set, so it will never execute any of the > > inside of the foreach($resultarray as ....) loop, hence the above code isn't > > really going to do a whole lot... > > Okay, my fault, I forgot to mention that I snipped parts of the code away to shorten it and to focus > attention on the matter in hand. An honourable intention. For which I am thankful. Better still is to snip away as much as possible, but then confirm that it still runs and fails as you expect :o). > > > It would be most helpful if you could attach .php/.xml/.html > > files that I can copy out and run and examine the output against your output > > to a) see if I get the same results and then b) work out if those results > > are "correct". > > Oh, I didn't do that in the first place - I reckoned you got tons of mails like this and wanted to > spare you the troubles. I do get a fair few mails, but if I get mails with php inline in the email, then all I end up doing is creating a junk.php file and pasting the php in then running it, so it's actually much easier if you just mail .php/.xml files in their entirity. What is annoying is getting php snippets with no xml to run them against. That means I have do debug by "inspection" which is much harder than by "iteration". There is however no need to mail me the XPath.class.php, as I have access to the source for that. Mentioning the cvs version of the file should be all that's necessary. > Anyhoo, I've attached 'bot_db.xml', 'cms_searchengine_createindex2.php', as > well as the 'xpath.class.php' I'm using. I've commented the code slightly. If I've left something in > a blur, I'll be happy and ready to clear things up. Ok I made a one line change to get rid of the index errors. You had: $myindex->appendData($myindex->appendChild($xmlpage,"item"),$itemvalue); Which should have read: $myindex->appendData($myindex->appendChild($xmlpage,"<item/>"),$itemvalue); And then I hit the 30 second execution time limit. So I trimmed the bot_db.xml down to just the first and last "pages" then re-ran and produced search_index.xml. Without studying the code in detail, search_index.xml looks "roughly" right. Is it? If not could you manufacture a small input .xml file, and then show me what the output.xml file should look like? Nigel |
From: Andreas S. <ts...@od...> - 2002-08-08 13:12:48
|
Could you please change the subject in this conversation? I mean, it's clear the man is not a doofus, and it could have a more helpful subject, like "appendData problem" or something ;) or maybe "I am not a doofus" ;) |
From: Nigel S. <nig...@us...> - 2002-08-08 13:17:26
|
I dunno, "doofus" is a kinda cool word, I like it :o) I usually use the term "numpty", but "doofus" is cool too. A agree though on both accounts, the user is niether a doofus, nor is the subject any good, and won't really assist anyone in looking for "support" from reading the list archive. Nigel =========================== For the most recent version of Php.XPath, and an archive of this list visit: http://www.sourceforge.net/projects/phpxpath ----- Original Message ----- From: "Andreas Skoufis" <ts...@od...> To: <php...@li...> Sent: Thursday, August 08, 2002 2:16 PM Subject: RE: Am I a doofus? > Could you please change the subject in this conversation? > > I mean, it's clear the man is not a doofus, and it could have a more helpful > subject, like "appendData problem" or something ;) > > or maybe "I am not a doofus" ;) > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Phpxpath-users mailing list > Php...@li... > https://lists.sourceforge.net/lists/listinfo/phpxpath-users > |
From: Nigel S. <nig...@us...> - 2002-08-06 14:25:59
Attachments:
Junk.php
JunkOutput.html
|
Odd, I just tested again and it works. I attach my .php file that I'm using to test, and the output it produces: What happens if you run Junk.php? Looking at the errors you are getting returned, something odd is up, because it is calling importFromString() BEFORE it has reached the appendChild() call. :o/ Nigel =========================== For the most recent version of Php.XPath, and an archive of this list visit: http://www.sourceforge.net/projects/phpxpath ----- Original Message ----- From: "Daniel Lucazeau" <inf...@aj...> To: <php...@li...> Sent: Tuesday, August 06, 2002 2:57 PM Subject: Re[2]: Am I a doofus? Bonjour Nigel, Le mardi 6 août 2002 à 02:19:52, vous écriviez : NS> $myroot = $myxpath->appendChild("","<superroot/>"); NS> However I just tried this and it didn't work, because the super root hadn't NS> been setup, so this is a bug for which I thank you kindly for reporting :o) NS> I've just implemented a change so that you can do this now. You'll find it NS> in CVS if you can't wait for the next release, or you would like to do some NS> testing :o) I need the same feature so I try the CVS version 1.111, but without success. I try : $xml = new XPath(); $rootPath = $xml->appendChild( "", "<xml/>"); And I get : XPath error in XPath.class.php:1586 In importFromString(): XML error in given string on line 1 column 0. Reason:syntax error XPath error in XPath.class.php:5155 XPath error in XPath.class.php:1586. Message: In importFromString(): XML error in given string on line 1 column 0. Reason:syntax error -- Cordialement, Daniel mailto:inf...@aj... ---------- Support-Assistance PHP/MySql de «Internet Pour Tous» http://www.i-p-t.com.fr/ :::XML/XSLT - Sablotron::: -- ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Phpxpath-users mailing list Php...@li... https://lists.sourceforge.net/lists/listinfo/phpxpath-users |
From: Daniel L. <inf...@aj...> - 2002-08-06 15:20:49
|
Bonjour Nigel, Le mardi 6 ao=FBt 2002 =E0 16:23:01, vous =E9criviez : NS> What happens if you run Junk.php? All is good ! It's me, I modify only the first call to =ABappendChild=BB, and let the others with a string. I focalize on the beginning of my code. Excuse-me ;-) Thanks for this great job. --=20 Cordialement, Daniel mailto:inf...@aj... ---------- Support-Assistance PHP/MySql de =ABInternet Pour Tous=BB=20 http://www.i-p-t.com.fr/ :::XML/XSLT - Sablotron::: -- |