Home › Forums › General XMetaL Discussion › Code Request: Process content with XSLT › Reply To: Code Request: Process content with XSLT
Reply to: Code Request: Process content with XSLT
April 3, 2009 at 1:09 pmIf you just return the id value from the XSLT instead of
the task is to remove the children of
and add a new attribute with the calculated value.Let me know if that was of help 🙂
[code]var objNode = ActiveDocument.documentElement;
// get list of all elements to change
var nodes2change= objNode.getNodesByXPath(“address”);
var node2change;
var strAddressId;
// Work through the list if length > 0
for (var index = 0; index < nodes2change.length; index++) {
 node2change = nodes2change.item(index);
 strAddressId = your_great_xslt_function( node2change );
 // remove old stuff
 while( node2change.firstChild ) {
  node2change.firstChild.removeChild;
 }
 // add new attribute
 node2change.setAttribute( “addressid”, strAddressId );
}[/code]