AnsweredAssumed Answered

ChildrenByXPath search with Contains doesnt work

Question asked by yons7 on Sep 6, 2010

I am trying to make a webscript that will allow me to do a search on a specific folder, on a specific attribute, i tried an exact search and it worked, i also tried a "starts-with" search and all was fine.
However a problem shows when i attempt to do a "contains" or "like search, which, as far as i understand are the only ways to search for characters anywhere in a string.

My code is basically like this :

model.nodes = node.childrenByXPath(searchText);                                         * this is within the webscript's JScript

searchText is this: "*//.[contains(@cm:name,'doc')]"                                             * Maybe I should mention that i send the search text from a browser url to the JScript

This code returns an error saying that it failed to execute the script, and gives me this exception org.jaxen.FunctionCallException: contains() usage: contains('pattern')

Since then I tried using this as searchText:     "*//@cm:name[contains('doc')]"           now it doesnt return an error but the results i get are not restricted to @name but rather the whole documents, As it seems to be performing a search within the documents' content rather than a search within their @name attribute.

I've had the same problem trying to use "like(@cm:name,'doc')" instead of "contains" as the search it performs does not restrict itself to @name but to all the documents attributes and text.

Any help would be greatly appreciated, been struggling for a couple of days now. Thank you in advance.