AnsweredAssumed Answered

Processing CMIS feeds in web scripts

Question asked by schambon on Feb 7, 2010
Hi,

I've been trying to process the results of /api/node/…/children in JavaScript with E4X, in another web script running in Surf.

I'm finding it… difficult. It appears that Rhino has a few bugs in E4X with namespaces:

- cannot filter based on namespaces (so, impossible to do "xml.entry.(cmis::object.cmis::properties.cmis::propertyString.(@cmis::name=="BaseType").cmis::value=="document")). One has to change the default namespace back and forth between Atom and CMIS. Unwieldy, but manageable.
This one I found documented on the Rhino bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=344779

- cannot actually get the value from a non-document-default-namespace attribute. I can't find any trace of it in Rhino forums / bugzilla, however I can't see what I'm doing wrong. Basically, the /api/node/…/children script returns an XML document with default namespace of Atom and imports the CMIS namespace. I can get values for Atom-namespaced attributes, but not from CMIS-namespaced attributes.

Typically:

var content = remote.connect("alfresco").get("/api/node/workspace/SpacesStore/<whatever>/children");
var xml = new XML(content.response.replaceAll("(?s)<\\?xml .*?\\?>\\s*", "")); // Workaround: Mozilla Bug 336551

default xml namespace="http://www.w3.org/2005/Atom";

var href = xml.entry[0].link[0].@href.toString(); // works

default xml namespace="http://docs.oasis-open.org/ns/cmis/core/200901";
var name = xml.atom::entry[0].object.properties.propertyString[0].@name.toString(); // doesn't work, returns nothing.

default xml namespace="http://www.w3.org/2005/Atom";
var name = xml.entry[0].cmis::object.cmis::properties.cmis::propertyString[0].@cmis::name.toString(); // doesn't work, returns nothing.

In the end I've whipped up a quick JSON script that gives me the same results and is lots easier to parse in Surf-webscript, but it's a little sad that I couldn't just use what's there.

So… Am I doing something wrong, am I hitting bugs in Rhino, should I raise issues in Rhino and in Alfresco JIRA, should I raise an issue over at Spring (since Surf and web scripts are now under the Spring umbrella)?

Outcomes