// if objectNode is the root of a store, parent-uuri.equals(""),
// thus we cannot call getFirstMapping because
// we cannot resolve the uuri
boolean useBinding = Configuration.useBinding(this) && !resourceId.isStoreRoot();
XMLValue result = new XMLValue();
Enumeration parentBindings = objectNode.enumerateParentBindings();
while (parentBindings.hasMoreElements()) {
ObjectNode.Binding parentBinding = (ObjectNode.Binding) parentBindings.nextElement();
Element parentElm = new Element("parent", NodeProperty.NamespaceCache.DEFAULT_NAMESPACE);
Element hrefElm = new Element("href", NodeProperty.NamespaceCache.DEFAULT_NAMESPACE);
String parentUriStr = new UriPath(objectNode.getUri()).parent().toString();
Uri parentUri = new Uri(uri.getToken(), uri.getNamespace(), parentUriStr);
String uriStr;
if (useBinding) {
ResourceId parentResourceId = ResourceId.create(parentUri, parentBinding.getUuri());
uriStr = getFirstMapping(parentResourceId);
}
else {
uriStr = parentUriStr;
}
hrefElm.setText(uriStr);
parentElm.addContent(hrefElm);
Element segmentElm = new Element("segment", NodeProperty.NamespaceCache.DEFAULT_NAMESPACE);
segmentElm.setText(parentBinding.getName());
parentElm.addContent(segmentElm);
result.add(parentElm);
}
return result.toString();
}