cancel
Showing results for 
Search instead for 
Did you mean: 

Namespace prefix problem in Xpath query using api

sureshs
Champ in-the-making
Champ in-the-making
Hi,

I have a space named RedArea inside company_home, my requirement is to retrieve the meta data/properties namely tags of all the documents(inserted at the time of upload) of that particular space,

When i used the following query in Node Browser of Alfresco, it gave me correct result. 

//cm:RedArea//@test:tags

but when i try to use the same in the following api, inside amps

List<Serializable> result = searchService.selectProperties(rootNodeRef, "//cm:RedArea//@test:tags", null, namespacePrefixResolver, false);
iam getting the following exception….

org.jaxen.UnresolvableException: XPath expression uses unbound namespace prefix cm org.jaxen.expr.DefaultNameStep.evaluate(DefaultNameStep.java:236) org.jaxen.expr.DefaultLocationPath.evaluate(DefaultLocationPath.java:154) org.jaxen.expr.DefaultAbsoluteLocationPath.evaluate(DefaultAbsoluteLocationPath.java:121) org.jaxen.expr.DefaultXPathExpr.asList(DefaultXPathExpr.java:112) org.jaxen.BaseXPath.selectNodesForContext(BaseXPath.java:688) org.jaxen.BaseXPath.selectNodes(BaseXPath.java:227) org.alfresco.repo.search.NodeServiceXPath.selectNodes(NodeServiceXPath.java:195) org.alfresco.repo.search.impl.NodeSearcher.selectProperties(NodeSearcher.java:255) org.alfresco.repo.search.impl.lucene.ADMLuceneSearcherImpl.selectProperties(ADMLuceneSearcherImpl.java:662) org.alfresco.repo.search.SearcherComponent.selectProperties(SearcherComponent.java:114) org.alfresco.repo.search.AbstractSearcherComponent.selectProperties(AbstractSearcherComponent.java:85) sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) sun.reflect.NativeMethodAccessorImpl.invoke


Can anyone please help me to solve the above issue…

Thanks in prior

Regards
Suresh.S
1 REPLY 1

merelv
Champ in-the-making
Champ in-the-making
Make sure the namespacePrefixResolver variable in your selectProperties method has the namespace cm registered.

So in your case, namespacePrefixResolver should be


DynamicNamespacePrefixResolver namespacePrefixResolver = new DynamicNamespacePrefixResolver(null);
namespacePrefixResolver.registerNamespace(NamespaceService.CONTENT_MODEL_PREFIX, NamespaceService.CONTENT_MODEL_1_0_URI);
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.