Howdy!
I have created a handy-dandy little Xalan Javascript component to add extended attributes to files that have been created through a redirect mechanism into a separate file (similar to how iw_ostream worked).
At the moment I'm kind of stumped as to how I would call the Interwoven javascript methods found in iwtools.xsl from my own "utils.xsl" that I'm creating.
As a temporary workaround I've copied all the functions from iwtools.xsl into my own utils.xsl file... It works... But it really sucks... What I really want to do is to reference the IW commands (iw:getArea, iw:getDcr, iw:run) and pull that file in. Any thoughts?
Here's the content of my script, since I figure it may help others:
function addExtendedAttributes(fullOutputFilePath) {
var outputDirectory = getOutputDirectory();
var outputFilename = getOutputFileName();
var area = getArea();
partialPath = outputDirectory.substr(area.length+1);
var pathAndFilename = '\\'+partialPath+'\\'+outputFilename;
var fullDcrPathAndFilename = getDcr();
var dcrFilename = fullDcrPathAndFilename.replace(/.*templatedata\/.*\/data\/(.*)/, '$1');
var documentType = fullDcrPathAndFilename.replace(/.*templatedata\/(.*)\/data\/.*/, '$1');
addSingleExtendedAttribute('TeamSite/Templating/PrimaryDCR', dcrFilename, fullOutputFilePath);
addSingleExtendedAttribute('TeamSite/Templating/PrimaryDocumentType', documentType, fullOutputFilePath);
addSingleExtendedAttribute('GeneratedOrOstreamed', 'ostreamed', fullOutputFilePath);
addSingleExtendedAttribute('GeneratedFile', pathAndFilename, fullOutputFilePath);
return '';
}
function addSingleExtendedAttribute(attributeName, attributeValue, filePath) {
var commandToExecute = 'cmd.exe /c /iw-home/TeamSite/bin/iwextattr -s "'+attributeName+'='+attributeValue+'" '+filePath;
run(commandToExecute);
}