Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

printf() Function (Python, SLAX, and XSLT)

Namespaces

Python Syntax

SLAX Syntax

XSLT Syntax

Description

Generate formatted output text. Most standard printf formats are supported, in addition to some Junos OS–specific formats. The function returns a formatted string but does not print it on call. To use the following Junos OS modifiers, place the modifier between the percent sign (%) and the conversion specifier.

  • j1—Operator that emits the field only if it changed from the last time the function was called. This assumes that the expression’s format string is unchanged.

  • jc—Operator that capitalizes the first letter of the associated output string.

  • jt{TAG}—Operator that emits the tag if the associated argument is not empty.

The prefix associated with the namespace URI should be defined in the prefix-to-namespace mapping in the style sheet.

Parameters

expression

Format string containing an arbitrary number of format specifiers and associated arguments to output.

Usage Examples

In the following example, the j1 operator suppresses printing the interface identifier so-0/0/0 in the second line of output, because the identifier argument has not changed from the first printing. The jc operator capitalizes the output strings up and down. The jt{--} operator does not print the {--} tag in the first line of output, because the associated output argument is an empty string. However, the tag is printed in the second line because the associated output is the non-empty string test.

produces the following output:

Release Information

Function introduced in Junos OS Release 7.6.

Support for the slax namespace http://xml.libslax.org/slax added in Junos OS Release 12.2.

Support for Python added in Junos OS Release 16.1R1.