One of my expressions for one of my Feed Importers is a count of a specific XML node. The count is often zero. However, for some reason it doesn't seem to want to store that value in the the actual Drupal Node. It doesn't throw any errors, and it doesn't change the value of the field. It will update the field just fine if the value is 1 or more, but as soon as the count is 0 it won't update.
The field in question on the Drupal node is Integer. I've also tried Text, but that doesn't work either, same behavior.
I know the XPath expression works because a) it works just fine any time the value is 1 or greater and b) I'm using XML Tree in Chrome and the expression always works and will return 0 when the count is really 0.
Any ideas?
Comment | File | Size | Author |
---|---|---|---|
#4 | feeds_xpathparser-get-falsy-values-1463232-4.patch | 1001 bytes | twistor |
Comments
Comment #1
cdmo CreditAttribution: cdmo commentedIs this a bug?
Comment #2
Robin Millette CreditAttribution: Robin Millette commentedMay be related to #1064536: How to deal with boolean fields.
Comment #3
cdmo CreditAttribution: cdmo commentedI feel like I should give more details, because it does sound like these are related.
Here's the xpath query:
count(/dlf:collection/dlf:record/dlf:items/dlf:item[ncsu:ExtendedItemData/ncsu:Status='TECHLEND' and ncsu:ExtendedItemData/ncsu:Library='DHHILL' and dlf:simpleavailability/dlf:availabilitystatus='available'])
Here's a sample of the feed
If the count is 1 or more, the feed imports fine into content type's field, whether it's an Integer or Text field. When the count is 0, it simply doesn't do anything, it doesn't return a zero, or a "false" or anything else, regardless of the field type.
I've tried to tamper by doing a filter on 0 and return "zero found" instead and that also doesn't work.
I'm guessing that it confuses 0 with FALSE, but you'd think it would return FALSE to a text field if that were the case. Can't quite figure this out.
Also, fwiw I've been using a handy Chrome extension called XML Tree to test queries. It's been very handy.
Comment #4
twistor CreditAttribution: twistor commentedCan you try this patch?
Comment #5
cdmo CreditAttribution: cdmo commentedThat fixed it! Thanks a bunch!
If you or anyone else is curious, we're using this module to fetch availability data for our technology lending program at our library. See:
http://www.lib.ncsu.edu/techlending/ and the laptop links on http://www.lib.ncsu.edu/techlending/laptops
Planning on rolling out availability data for more of our lending items too. Thanks again.
ps. this is my first patch I've rolled into production. Will I just need to re-apply the patch when there are updates or does this patch get included into the next module update? Just curious.
Comment #6
Robin Millette CreditAttribution: Robin Millette commented@cdmo: The patch will probably get commited with a message posted here, and its status changed to "fixed" meaning it will be available in the next -dev tarball and eventually, in the next stable release.
Comment #7
cdmo CreditAttribution: cdmo commentedGreat, thanks for explaining.
Comment #8
Robin Millette CreditAttribution: Robin Millette commented@cdmo: you could also get fancy with drupal make and have that handle the patch :-)
Comment #9
twistor CreditAttribution: twistor commentedThanks for the review!
It will be in the next release.
committed to 7.x
http://drupalcode.org/project/feeds_xpathparser.git/commit/72de431
Comment #10
twistor CreditAttribution: twistor commented6.x
http://drupalcode.org/project/feeds_xpathparser.git/commit/76e231b