We have a document type (Articles) that contains a multi-value property of which is another document type (Categories). These document types are in multiple languages with each language having it’s own root folder.
Articles of one language should only contain categories from that of it’s own language. We are trying to create an XPath query to return all articles that contain at least one Category of a different root folder (e.g. en/US Article containing an en/CA Category) .
Since our system contains a large number of Articles we are trying to avoid looking trough every Category within every Article individually, whilst trying to make this as quick as possible and XPath query seems to be the best option.
We have tried multiple queries similar to the following but have had no luck preventing Articles that solely contain Categories from the en/US folder from being returned:
/jcr:root/content/documents/en/US//element(*,EAP:Article)[@EAP:categories/hippo:docbase!='5455b164-b7fa-4cc9-b180-bfdd3d71ccf7' and @EAP:categories/hippo:docbase!='8ec09a26-15a0-49ac-8dfc-33a8999fd247' and @EAP:categories/hippo:docbase!='6b4e3185-d50d-440f-af12-fae4cc0f2b47' and @EAP:categories/hippo:docbase!='3f7b6359-5d6c-4a0d-a091-1d84f73775b4' and @EAP:categories/hippo:docbase!='cafebabe-cafe-babe-cafe-babecafebabe']
Hi,
If you don’t have too many Canadian category documents perhaps you can do [@EAP:categories/hippo:docbase = ‘uuid1’ or @EAP:categories/hippo:docbase!=‘uuid2’ where uuid1 and uuid2 are the handle uuids or the Canadian ones of course.
Otherwise maybe prevent earlier to not select Canadian categories from US articles?
HTH
Jeroen
Hi Razvan, thank you for the response. I did it slightly differently since the path from where I need to fetch the document was fixed. This is what I did:
// get the resource bundle node
Node node = context.getSession()
.getRootNode()
.getNode(RESOURCE_BUNDLE_FOLDER_PATH)
.getNode(bundleId);
// get the Hippo document
HippoDocument document = (HippoDocument) context.getObjectConverter().getObject(node);
// collect the keys and values in a Map
Value[] keys = document.getNode().getProperty(PROP_KEYS).getValues();
Value[] values = document.getNode().getProperty(PROP_MESSAGES).getValues();
Map<String, String> bundle = new HashMap<String, String>();
for (int i = 0; i < keys.length; i++) {
bundle.put(keys[i].getString(), values[i].getString());
}