cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Tracking information removal - atict:info and atict:user - ACL scripting

ptc-4796391
1-Visitor

Tracking information removal - atict:info and atict:user - ACL scripting

Hi all


I am trying to remove the tracking information from the XML using the ACL scripting, I tried to use the 'xpath_nodeset' function to find the atict:elements with the correct XPath however it looks like the 'atict:' elements are somehow hidden. I also tried to use 'set changetrackingmarkers=full' to show the tracking elements however I was still not able to get the oid of the atict:elements with the 'xpath_nodeset' to be able to remove it.


Basically, I want to remove 'atict:info' and 'atict:user' after checking the attribute '@tracking' from 'info' element, if it is set to 'off' and there is no other atict:element (except for the 'info' and 'user') then both info and user elements should be removed from the XML. I hope it makes sense...


As always any help with this would be much appreciated! 😉


Thanks


Marcin


12 REPLIES 12

Hi again


I managed to find the element 'atict:info' in the document using the oid_find_children, it is really weird that there is no support for xpath for the "kind-of processing instructions",however I can't remove the oid as it says it is protected, I have set the protection to none, any ideas?:)


Thanks


Marcin



The code:


oid_find_children(oid_root(doc), $nodeset, "atict:info");
for ($i in $nodeset) {
if (oid_has_attr($nodeset[$i], "tracking")) {
trackingAttr = oid_has_attr($nodeset[$i], "tracking");
if (trackingAttr){
debug("weszlo do off ;-)");
debug($nodeset[$i]);
trackingAttrValue = oid_attr($nodeset[$i], "tracking");
debug(trackingAttrValue);
if (trackingAttrValue == "off"){
debug("protected: ");
debug(oid_protected($nodeset[$i]));
debug("delete: ");
debug(oid_delete($nodeset[$i], 1));
set protection=none
oid_delete($nodeset[$i], 1);
}
#oid_delete($nodeset[$i]);
}

}
}

Marcin,


First, I'd start with checking to see if the document has any change tracking within the document before I looked for it. You can do that with doc_has_change_tracking( doc ), which will return a '0' if there is NO change tracking elements within the document. If it returns a '1', there is at least 1 occurrance of change tracking, in which case you can abort the process.


Next, you can test for whether or not change tracking is on. The tracking attribute you talk of is set to "on" when the "changetracking" status of the document is set to on. You can test that condition using the doc_get( doc, "changetracking" ).


Once you find out that you have no change tracking within the document and change tracking is turned off, you then can remove the <atict:info> and <atict:user> tags.


Because these two tags are protected tags, you cannot remove them by using the oid_delete() command. Instead, you can selet them and delete the selection.


The code I'd try:



$doc = current_doc() ;

# only continue if there is NO change tracking within the document.

if ( !doc_has_change_tracking( $doc ) ) {

  # only continue if Change Tracking is not turned on.

  if ( doc_get( $doc, "changetracking" ) == '0' ) {

    # find any atict:info tags

    oid_find_children( oid_root( $doc ), $atiOids, 'atict:info' ) ;

    # for each tag found, delete it.

    for ( $i in $atiOids ) {

      oid_select( $atiOids[ $i ], 1, 1, 1 ) ;

      delete_mark ;

    }

    # find any atict:user tags.

    oid_find_children( oid_root( $doc ), $atiOids, 'atict:user' ) ;

    # for each tag found, delete it.

    for ( $i in $atiOids ) {

      oid_select( $atiOids[ $i ], 1, 1, 1 ) ;

      delete_mark ;

    }

  }

}


Hope this helps,


Bob

Hello.

Why do you not use "Tools/Change Tracking/Accept or Reject Changes" menu functionalities ?
It's less tricky than manipulating atict tags through ACL code, and Accept or Reject functions should remove atict tags.

Regards

Sébastien

Le 29/10/2012 12:41, Marcin Rachocki a écrit:

Hi again
I managed to find the element 'atict:info' in the document using the oid_find_children, it is really weird that there is no support for xpath for the "kind-of processing instructions",however I can't remove the oid as it says it is protected, I have set the protection to none, any ideas?:)
Thanks
Marcin

The code:
oid_find_children(oid_root(doc), $nodeset, "atict:info");
for ($i in $nodeset) {
if (oid_has_attr($nodeset[$i], "tracking")) {
trackingAttr = oid_has_attr($nodeset[$i], "tracking");
if (trackingAttr){
debug("weszlo do off ;-)");
debug($nodeset[$i]);
trackingAttrValue = oid_attr($nodeset[$i], "tracking");
debug(trackingAttrValue);
if (trackingAttrValue == "off"){
debug("protected: ");
debug(oid_protected($nodeset[$i]));
debug("delete: ");
debug(oid_delete($nodeset[$i], 1));
set protection=none
oid_delete($nodeset[$i], 1);
}
#oid_delete($nodeset[$i]);
}

}
}
Site Links: View post online View mailing list online Send new post via email Unsubscribe from this mailing list Manage your subscription


Use of this email content is governed by the terms of service at:

Sébastien,


Most likely, Marcin needs to strip the remanants of Change Tracking for some other reason. While it's true that using the menu will allow you to rid the document of any change tracking, it will not remove the embedded tags for tracking what the status is of the Change Tracking, nor will it remove the user information from the document.


Bob

Hi


Bob, Thanks a lot for this, I didn't expect the code to be just given to me, that is really great. ;-).


Sébastien, as Bob said your solution will not remove the atict: mark-up from the XML and that is my goal for this task.


Once again, many thanks.


Marcin

I recently had to unprotect some markup before modifying it. It is specific
to a product now called DLM but originally named DCAM. The command was:

set protectdcam = off;

I also played with (although if I remember correctly it didn't end up being
needed):

set protection = none;

For fun I tried "set protectatict = off" but that didn't work. Anyhow, a
possible avenue of research if the ideas already presented don't get you to
where you need to be.



Hi Bob/all


I am stuck again:). It appears that the delete_mark is removing the atict: elements from 'arbortext view' however it is not removing it from the XML, when I run delete_mark, close the document, open it again the atict:info and atict:users are back in the document. Any clue how can I remove it from the XML mark-up?


Thanks


Marcin



In Reply to Bob Spangenburg:



Marcin,


First, I'd start with checking to see if the document has any change tracking within the document before I looked for it. You can do that with doc_has_change_tracking( doc ), which will return a '0' if there is NO change tracking elements within the document. If it returns a '1', there is at least 1 occurrance of change tracking, in which case you can abort the process.


Next, you can test for whether or not change tracking is on. The tracking attribute you talk of is set to "on" when the "changetracking" status of the document is set to on. You can test that condition using the doc_get( doc, "changetracking" ).


Once you find out that you have no change tracking within the document and change tracking is turned off, you then can remove the <atict:info> and <atict:user> tags.


Because these two tags are protected tags, you cannot remove them by using the oid_delete() command. Instead, you can selet them and delete the selection.


The code I'd try:



$doc = current_doc() ;

# only continue if there is NO change tracking within the document.

if ( !doc_has_change_tracking( $doc ) ) {

  # only continue if Change Tracking is not turned on.

  if ( doc_get( $doc, "changetracking" ) == '0' ) {

    # find any atict:info tags

    oid_find_children( oid_root( $doc ), $atiOids, 'atict:info' ) ;

    # for each tag found, delete it.

    for ( $i in $atiOids ) {

      oid_select( $atiOids[ $i ], 1, 1, 1 ) ;

      delete_mark ;

    }

    # find any atict:user tags.

    oid_find_children( oid_root( $doc ), $atiOids, 'atict:user' ) ;

    # for each tag found, delete it.

    for ( $i in $atiOids ) {

      oid_select( $atiOids[ $i ], 1, 1, 1 ) ;

      delete_mark ;

    }

  }

}


Hope this helps,


Bob


Marcin,


Taking you in a different direction here, but have you looked at the "write -changesapplied ..." command? (Not the function btw.)


The writecommand creates acopy of thefile. -changesapplied switch is the equivalent of accept all change tracking and also strips the atict:info and atict:user tags.


- Lou Argyres


Continuing Education of the Bar (CEB)


Oakland CA

Hi Lou


Thanks for the reply. Yes, I had a look at the PTC Support website where it mentions that specific command which they state that it is a workaround for the atict problem however as you say the write command creates a copy - is it possible to replace the current_doc() with that copy? We want to have this automated so that editor doesn't have to do an additional task, everything should be behind the scene. I am quite new to Arbortext customizations so any help would be much appreciated. 🙂


Thanks again


Marcin



In Reply to Lou Argyres:



Marcin,


Taking you in a different direction here, but have you looked at the "write -changesapplied ..." command? (Not the function btw.)


The writecommand creates acopy of thefile. -changesapplied switch is the equivalent of accept all change tracking and also strips the atict:info and atict:user tags.


- Lou Argyres


Continuing Education of the Bar (CEB)


Oakland CA


Marcin,


Before you work on the document with the code I already mentioned, firstturn off "Change Tracking" through the Tools menu, or with <ctrl+shift+e>. There is a "TRK" in the bottom-right of the Editor window that should begrayed out indicating that Change Tracking is OFF. You want it grayed out. Then run the code I mentioned. With Change Tracking still OFF, save your document.


With it ON, you will get the current status of your Change Tracking environment, including the user, stored at the top of your document with the atict: tags.


Hope this helps,


Bob

Hi


Sharing as maybe someone will need to do similar thing. The only bit missing is to somehow remove the temp file on close however I was unsuccessful with that as it is still 'in use' when you use destroy callback.


If anyone has experience with temp files please do let me know what's the best approach.


Thanks


Marcin



# only continue if there is NO change tracking within the document.


if ( !doc_has_change_tracking( $doc ) ) {

# only continue if Change Tracking is not turned on.

if ( doc_get( $doc, "changetracking" ) == '0' ) {

#global $currentPath = doc_path(current_doc());
#global $tempPath = $currentPath.'.temp';


#save current as temp
save_as -xml '$tempPath'
#remove currentPath file (the original name)
remove_file -f '$currentPath'
#write to original name without atict:info atict:users
write -ct changesapplied -xml '$currentPath'
#close temp, open current, remove temp?
}
}

Hi again Marcin,


I don't know the particulars, but the "save_as" creates a lock or destroy callback conflict that can't be avoided even with the "-ok" switch (overwrite without prompting) in the "write" command. The fastest way would be to use "move_file [oldname newname]" to rename files.


local myfile = doc_path(current_doc());
local file_tmp = myfile . "_temp.xml";

write -ok -ct changesapplied -pi "$file_tmp";
set modified=off; #avoid save prompt
file_close();

move_file $file_tmp $myfile;
edit -newwindow -xml "$myfile";


- Lou Argyres
Continuing Education of the Bar (CEB)
Oakland CA

Announcements

Top Tags