cancel
Showing results for 
Search instead for 
Did you mean: 

xPath explanation

mannobug
Champ in-the-making
Champ in-the-making
Hi all i have a little question that is a problem cause i really don't understand wht's worng.
I'm new and i'm try to develop an application that i want use in web environment. Using web services  i'd like to retrive document list in alfresco repository.
I have this structure in Company Home:
WiFi -> Retailers -> 999 -> Accounting. 999 are subspace of Retailers and so on.
Using Query2 Sample (http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/sdk/samples/WebServic...) i define a variable STORE like new Store (Constants.WORKSPACE_STORE, "SpacesStore") and id liek to get reference to Accounting space using reference and repositoryservice.
So i did….


String xpath = "app:/company_home/cm:WiFi/cm:999/*[@cm:name="Accounting"]";
Reference reference = new Reference(STORE, null, xpath);
Predicate predicate = new Prodicate(new Reference[]{reference}, null, null);
Node[] nodes = repositoryService.getPredicate(predicate);

At this point i get an exception Axis Fault….Error Executing xpath…RepositoryFault….  Smiley Surprised
But how can?? this is not the right way to use Xpath???
Thx for Help
Ema
4 REPLIES 4

mannobug
Champ in-the-making
Champ in-the-making
….of ourse using // instead of /. The way to say descendant-or-self.
Thx 😄
Ema

mannobug
Champ in-the-making
Champ in-the-making
….well in fact using numbers in space's name result in strange behaviur. E.g.:
with this xpath:

app:/company_home/cm:WiFi/cm:User-999/cm:Accounting
it works, and wioth this one:

app:/company_home/cm:WiFi/cm:999-User/cm:Accounting
it doesn't!(Obviusly changing name of the space during this test).

Is it a correct behaviour???  :?
Ema

mahkath
Champ in-the-making
Champ in-the-making
Hi,

Try using Query in the below format.

Query query = new Query(Constants.QUERY_LANG_LUCENE, "+PATH:\"/app:company_home/cm:templates//*\" + @cm\\:name:*xml");

In the above Query I'm searching for XML file in /app:company_home/cm:templates space.

More over you are using space which is starting with Number(999). First encode the folder/Filename which is starting with number or has spaces and then try quering the Alfresco.
For encoding use ISO9075.encode("999");

Regards,
Mahesh

mannobug
Champ in-the-making
Champ in-the-making
Hi mahkath 😄 thx for your reply…It works
ISO9075.encode("999");
and of course the query that you write.
Thanks again 😄
Ema