cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble querying node properties

dwinfield
Champ in-the-making
Champ in-the-making
Hi all,

I'm having trouble querying for the "url" values of the links.  I wanted to do two things, get a distinct list, and filter links based on the url. 

Looking at http://wiki.alfresco.com/wiki/Search_Documentation#Examples I found some queries that sort of did what I want.  So I modified it and got this query
"//.[@lnk:url='*']"

Unfortunately I get nothing back.

Full code I'm using

      DynamicNamespacePrefixResolver namespacePrefixResolver = new DynamicNamespacePrefixResolver(null);
      namespacePrefixResolver.registerNamespace(NamespaceService.ALFRESCO_PREFIX, NamespaceService.ALFRESCO_URI);
      namespacePrefixResolver.registerNamespace("lnk", "http://www.alfresco.org/model/linksmodel/1.0");
      
      
      List<Serializable> rs = this.searchService.selectProperties(original, "*//.[@lnk:url]", null, namespacePrefixResolver, true);

the variable "original" is either the links folder in the site OR it's an actual link I had created in the site.  I wasn't sure if this code had to be run on the folder or the link, so I tried both.

For the filter, I would change the Xpath query to "*//.[@lnk:url=<WHATEVER_IS_ PASSED_IN>]"
I got the registration for the uri and prefix by looking at Repository/config/alfresco/model/linksModel.xml

Anyone with any ideas?
2 REPLIES 2

dwinfield
Champ in-the-making
Champ in-the-making
I've gotten a bit further, running this query under the node browser, I get what I want, sorta.  I choose "selectnodes" as the searchlanguage (although I read that that's really xpath?)

/app:company_home/st:sites/cm:ealabs/cm:toolsmatrix//.[@lnk:company]

However the following javascript seems to make my webscript just absolutely die.
The code is
query = "/app:company_home/st:sites/cm:ealabs/cm:toolsmatrix//.[@lnk:company]"
         var rs = search.xpathQuery(query);


I don't get an error, I just get the message from firefox that "Firefox can't find the file at blahblahblahblahblah-really-long-url".  However as soon as I uncomment the second line, the one executing the xpathQuery, everything is good to go.

Anyone with an idea?

Dave

dwinfield
Champ in-the-making
Champ in-the-making
I decided to just use
companyhome.childrenByXPath(query);

I think the problem was I wasn't specifying a store, but I'm not sure.