Add style sheet tag to CCDA

Suppose,  consider you have developed a CCDA from your Mirth and you are writing this to your destination folder. But when the CCDA is written in the file, it should also print XML style sheet tag, to enable human readability. which will be like this.

<?xml-stylesheet type=”text/xsl” href=”testCDA.xsl”?>

You can add this in your generated CCDA by providing this template in the file writer destination on the template section. If not, you can just append this entire tag as a string to the generated XML.

var outputFile = “D://CCDAOutput/”;
var nameData = “filename.xml”;
var humanReadable= ‘<?xml-stylesheet type=”text/xsl” href=”testCDA.xsl”?>’+’\n’;
FileUtil.write(outputFile+nameData, false,humanReadable+output);

Here the FileUtil.write is just works like a file writer destination. outputFile+nameData are directory path and filename, false is denoted for appending the file, weather to append on the same file or not, if not needed of appending then this field can be false, else true.

Leave a Comment