I'd like to use some Xpath functions, but I can't seem to make it work ..
My context is : /programs/program
With this, I can easily access my title, date, etc .. fields, which are nodes from a program
Now I want to combine 2 strings, so I tried the concat function, by typing :
concat(from_date, to_date) but it doesnt seem to work
I've also tried :
- concat(/programs/program/from_date, /programs/program/to_date)
- fn:concat(from_date, to_date)
But to no avail.
Is it because the context is put before that function ? Or am I using the wrong syntax ?
I've tried other functions, but I can't seem to get any of them to work
Comments
Comment #1
twistor commentedThe context shouldn't affect anything. Can you give me a specific example?
Comment #2
copyhold commentedsubscribe
Does XPath functions work?
Comment #3
netw3rker commentedI'm running into a similar problem i cant get concat to work at all. here's an xml excerpt:
settings that don't work:
context = //area
guid = @area_id
title = concat(@countrycode, ' - ', @name)
settings that do work:
context = //area
guid = @area_id
title = @name
does the xpath function for concat work with this module or are only paths to data allowed? also note that it does create all of the nodes, and does not throw an error, it just leaves the title blank (in this case).
This is sort of an important thing because when importing many peices of content that might have the same id# for the guid, it will help to be able to concat something that will make it more unique.
Comment #4
Andyj2106 commentedSubscribing...
I also can't get concat to work and my example is very similar to the above. All other fields in the context are accessible and being used in creating the node, including the two fields that are being concatted. As I use the concat in the GUID, I get one node created, with 3 revisions, instead of 3 nodes with 1 revision each, because I have 3 items in the XML that should be unique based on the concatenation of 2 pieces of data.
Comment #5
kyen99 commentedSame problem here. And without xpath functions, I can't even see a way to use the variable substitution, since simply putting a variable in the mapping field results in an error from trying to parse the value of the variable. It would seem that to use a variable you would need to do: string($variable), but this doesn't work either.
Comment #6
twistor commentedThe variable needs to be in quotes, "$variable". This probably isn't correct behavior, it should probably be quoted beforehand, if it's a string.
Comment #7
twistor commentedI've been all around the internet, trying to find info about this problem. The only only information I have been able to find was on an IBM site. "SimpleXML only supports XPath location paths and unions of location paths. It does not support XPath expressions that do not return node-sets, such as count(//para) or contains(title)." This is probably a good time to start thinking about a switch to the dom from SimpleXML.
As a workaround, although not ideal, concat and various string emulations can be emulated with feeds_tamper.
Comment #8
twistor commentedOk, so I rewrote the parsing to use DOMXPath instead of SimpleXML. It seems to be working ok, but I'll need people to tests it out before I release it.
Functions are working as expected!
Comment #9
twistor commentedhttp://drupal.org/cvs?commit=495568
Comment #10
twistor commentedComment #12
zazinteractive commentedI think the latest dev broke this feature again
EDIT: My bad. I upgraded to the stable release by accident, not the dev version. Sorry about that.
Comment #13
john bickar commentedI have been testing this (the concat() function) with the -dev version and it works great.
Any chance of rolling a stable release with this functionality?
Thanks!
Comment #14
twistor commentedOn their way.
Comment #15
jjmackow commentedIs there any support for the date functions? I'm trying queries with year-from-dateTime and similar date functions but getting an error within the
admin/build/feeds/edit/{NAME_OF_MY_IMPORTER]/settings/FeedsXPathParserHTML screen of "Unregistered function".
I've got a question though?
considering line 11 of FeedsXPathParserDOMXPath.inc
class FeedsXPathParserDOMXPath extends DOMXPath {...
and looking at DOMXPath in PHP, is it possible to use PHP's own date functions?
http://www.php.net/manual/en/domxpath.registerphpfunctions.php