Hi everyone,
To those currently at PTC user, please harass everyone you can get a
hold of for better documentation of the oid traversal flags 🙂
Anyway, I was working on a function that was attached to the save on a
doc_add_callback to traverse the oid tree and change an attribute value
on any element that tested positive for oid_modified. I was stumped at
first until the oid traversal email came through.
I'm getting pretty close, but one last hitch has me stumped; I have a
funny feeling I'm missing something trivial...
Anyway, the problem is the traversal flag works, except it now thinks
that every child of oid_root() is a modified element. Not where I was
hoping to go with that.
Here's the code...
function rev_update(doc,op) {
if(op == 1) {
local flag = 0x4 | 0x8 | 0x10 | 0x20 | 0x80 | 0x100 | 0x200 |
0x400
local curr_rev=oid_attr(oid_root(),'revlevel');
ret = oid_xpath_nodeset(oid_root(),element,'//*');
for(e in element) {
local oid = oid_child(element[e], 1, flag);
while(oid_valid(oid,flag)) {
if(oid_modified($element[$e], flag)) {
$att_chg=oid_modify_attr($element[$e],'revlevel',$curr_rev)
}
oid = oid_forward(oid, flag)
}
}
}
}
I thought maybe there was a sticky value that was picking up when the
oid_modified was testing, but I can modify the last element in a
document, and it still flags every element that is a child of root.
Any ideas?
Thanks,
-Jason