Printing unformatted output to the screen is sufficient for some scripts, but in many cases it is more user-friendly to have formatted script output where each line follows the same column spacing. The jcs:printf() function is used in op scripts for this purpose. It returns a string based on the formatting instructions and values provided in the arguments. Starting 12.2, slax:printf() can also be used instead of jcs:printf().

The syntax for jcs:printf() is the following: 
jcs:printf( "expression", value1, value2, ..., valuex );

The string expression contains embedded placeholders that indicate where each value should be inserted, as well as the format in which they should be placed. Here is an example:
<output> "123456789012345678901234567890";
<output> jcs:printf("%-10s%-10s","OSPF","ISIS" );
<output> jcs:printf("%10s%10s", "OSPF", "ISIS" );

There are two embedded placeholders in the expression of each of these jcs:printf() function calls. An embedded placeholder is indicated by a % followed by any flags, the width of the field, and the value type. In the first case, the %-10s indicates that a string value is inserted in a 10 space column that is left justified. This is repeated twice, once for “OSPF” and once for “ISIS”. In the second case, the size and number of fields are the same but they lack the flag, which causes them to be right justified.

version 1.0;

ns junos = "*/junos";
ns xnm = "";
ns jcs = "";

import "../import/junos.xsl";

match / {
    <op-script-results> {
        /* get-day-of-week returns the day – assign it to $day-of-week */
        var $day-of-week = { call get-day-of-week(); }
        /* Output day string to the console */
        <output> jcs:printf("%10s", $day-of-week);

/* Extract the day of week string from the $localtime global parameter */
template get-day-of-week {
    /* Write the first three characters of the $localtime to the result tree */
    expr substring( $localtime, 1, 3 );