libyang  1.0.184
YANG data modeling language library
Printing Schemas

Schema printers allows to serialize internal representation of a schema module in a specific format. libyang supports the following schema formats for printing:

  • YANG

    Basic YANG schemas format described in RFC 6020 and RFC 7951 (so both YANG 1.0 and YANG 1.1 versions are supported).

  • YIN

    Alternative XML-based format to YANG - YANG Independent Notation. The details can be found in RFC 6020 and RFC 7951.

  • Tree

    Simple tree structure of the module where each node is printed as:

    <status> <flags> <name> <opts> <type> <if-features>
    
    • <status> is one of:
      • + for current
      • x for deprecated
      • o for obsolete
    • <flags> is one of:
      • rw for configuration data
      • ro for status data
      • -x for RPCs
      • -n for Notification
    • <name> is the name of the node
      • (<name>) means that the node is a choice node
      • :(<name>) means that the node is a case node
      • if the node is augmented into the tree from another module, it is printed with the module name as <module-name>:<name>.
    • <opts> is one of:
      • ? for an optional leaf or choice
      • ! for a presence container
      • * for a leaf-list or list
      • [<keys>] for a list's keys
    • <type> is the name of the type for leafs and leaf-lists
      • if there is a default value defined, it is printed within angle brackets <default-value>
      • if the type is a leafref, the type is printed as -> TARGET`
    • <if-features> is the list of features this node depends on, printed within curly brackets and a question mark {...}?
  • Info

    Detailed information about the specific node in the schema tree. It allows to print information not only about a specific module, but also about its specific part:

    • absolute-schema-nodeid

      e.g. /modules/module-set-id in ietf-yang-library module

    • typedef/typedef-name

      e.g. typedef/revision-identifier in ietf-yang-library module

    • feature/feature-name

      e.g. feature/ssh in ietf-netconf-server module

    • grouping/grouping-name/descendant-schema-nodeid

      e.g. grouping/module or grouping/module/module/submodules in ietf-yang-library module

    • type/leaf-or-leaflist

      e.g. type/modules/module-set-id in ietf-yang-library module

Printer functions allow to print to the different outputs including a callback function which allows caller to have a full control of the output data - libyang passes to the callback a private argument (some internal data provided by a caller of lys_print_clb()), string buffer and number of characters to print. Note that the callback is supposed to be called multiple times during the lys_print_clb() execution.

Functions List

  • lys_print_mem()
  • lys_print_fd()
  • lys_print_file()
  • lys_print_path()
  • lys_print_clb()