At any given point in time there will always be one root element, you should be using getChildren()
A small update the generic form api code actually parses thru the entire tree , its able to return all the elements( Name & type ) correctly.I am trying to set all Item.getType() == 'browser' as read only using IWDatacapture.getItem(get_chidren).setReadOnly(true);even through Item.getType() == 'browser' matches a couple of times , setreadonly fails after the first attempt.In other words I am able to parse thru the tree , get all relevant elements , the program exits after setting the first element to read only , if I dont set any element to readonly then it finishes thru the entire tree.KannanTS 6.1.0 Service Pack 2 on Solaris 9
...function processroot(Item) {Items = Item.getChildren() ; if (Items != null) { for (var i = 0 ; i < Items.length ; i++) {Items = Item.getChildren() ; processChildren(Items[i]) ; } }}...
// I prefer a top-down approach ...function init() { navigate_structure("");} function navigate_structure(item) { if (item == ""){// Note: I take the 0th element only //Not sure if this changes for "iwov" style DCTs, only tested with "xml" style item = IWDatacapture.getRootItems()[0]; }// recurse if we have a container or replicant if (item.getType().match(/(container|replicant)/)){ var children = item.getChildren(); for (var idx = 0; idx < children.length; idx++){ navigate_structure(children[idx]); } } else {// otherwise, process the item - test for what we want in another function process_item(item); }}function process_item(item){// here's where you test and do what you want if (item.getType() == "browser"){ item.setReadOnly(true); }}
thanks very muchI totally agree with you .. The code that was attached had no indenting & no formatting.the original code which works was "IWDatacapture.getItem("/page[1]/article[1]/articleImage").setReadOnly(true)"from one liner ..it grew by copy pasting to the code which I had attached earlier.today after a bit more searching I found http://devnet.interwoven.com/forums_vb/showthread.php?t=5151&forumid=13I am just adding the following lineif ( itemObj.getType() == 'browser'){IWDatacapture.getItem(itemObj.getName()).setReadOnly(true) }its able to set the value as readonly for the firsttime and after that it fails.
Here comes the code exactly same as in http://devnet.interwoven.com/forums_vb/showthread.php?t=5151&forumid=13except for the condition to set type = browser to readonly.As mentioned earlier the code sets only the first `browser` element to readonly .where do i need to look for errors ??
function genIdentity(itemObj) {var children = itemObj.getChildren();if ( itemObj.getType() == 'browser'){IWDatacapture.getItem(itemObj.getName()).setReadOnly(true) }if (children) {for (var j=0;j<children.length;j++) {var replicantchildren = children.getChildren();if (replicantchildren) {for (var k=0;k<replicantchildren.length;k++) genIdentity(replicantchildren);}else genIdentity(children);} }}