Navigation
Guide That Contains This Content
[+] Expand All
[-] Collapse All
     

    Related Documentation

     

    printf() Function (jcs and slax Namespaces)

    Namespaces

    http://xml.juniper.net/junos/commit-scripts/1.0http://xml.libslax.org/slax

    SLAX Syntax

    expr prefix:printf(expression);

    XSLT Syntax

    <xsl:value-of select="prefix:printf(expression)"/>

    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.

    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.

    <xsl:value-of select="jcs:printf('%-24j1s %-5jcs %-5jcs %s%jt{ -- }s\n',
                 'so-0/0/0', 'up', 'down', '10.1.2.3', '')"/>
    <xsl:value-of select="jcs:printf('%-24j1s %-5jcs %-5jcs %s%jt{ -- }s\n',
                 'so-0/0/0', 'down', 'down', '10.1.2.3', 'test')"/>

    produces the following output:

    so-0/0/0        Up    Down  10.1.2.3
                  Down    Down  10.1.2.3 -- test
    
     

    Related Documentation

     

    Published: 2013-03-05