Juniper JUNOS OS 10.3 - XML MANAGEMENT PROTOCOL GUIDE 6-30-2010 Manual page 249

Junos xml management protocol guide
Hide thumbs Also See for JUNOS OS 10.3 - XML MANAGEMENT PROTOCOL GUIDE 6-30-2010:
Table of Contents

Advertisement

Copyright © 2010, Juniper Networks, Inc.
print STDERR "ERROR: Invalid XSL file $xslfile\n";
}
The first line of the preceding code sample illustrates how the scripts read the
from the command line to obtain the name of the file into which to write the results of
the XSLT transformation:
my $outputfile = $opt{o} || "";
From the
-x
command-line option, the scripts obtain the name of the XSLT file to use,
setting a default value if the option is not provided. The scripts exit if the specified file
does not exist. The following example is from the
my $xslfile = $opt{x} || "xsl/text.xsl";
if ($xslfile && ! -f $xslfile) {
die "ERROR: XSLT file $xslfile does not exist";
For examples of XSLT files, see the following directories in the Junos XML protocol
Perl distribution:
The
examples/diagnose_bpg/xsl
script:
generates dynamic HTML,
dhtml.xsl
generates ASCII text.
The
examples/get_chassis_inventory/xsl
script:
get_chassis_inventory.pl
comma-separated values,
chassis_inventory_xml.xsl
The actual parsing operation begins by setting the variable
form
and invoking the
device-name.xml
server's response into the file (the
module):
my $xmlfile = "$deviceinfo{hostname}.xml";
$res->printToFile($xmlfile);
The next line invokes the
translateXSLtoRelease
module) to alter one of the namespace definitions in the XSLT file. This is necessary
because the XSLT 1.0 specification requires that every XSLT file define a specific value
for each default namespace used in the data being transformed. The
a Junos XML operational response tag element includes a code representing the Junos
OS version, such as
10.3R1
same XSLT file can be applied to operational response tag elements from devices running
different versions of the Junos OS, the XSLT file cannot predefine an
value that matches all versions. The
definition in the XSLT file identified by the
XML protocol server's response. It assigns the resulting XSLT file to the
Chapter 9: Writing Junos XML Protocol Perl Client Applications
diagnose_bgp.pl
directory contains XSLT files for the
html.xsl
directory contains XSLT files for the
chassis_inventory_csv.xsl
chassis_inventory_html.xsl
generates XML.
function to write the Junos XML protocol
printToFile
printToFile
function is defined in the
function (defined in the
for the initial version of Junos OS Release 10.3. Because the
translateXSLtoRelease
$xslfile
variable to match the value in the Junos
-o
script:
diagnose_bpg.pl
generates HTML, and
text.xsl
generates a list of
generates HTML, and
to a filename of the
$xmlfile
XML::DOM::Parser
Junos::Response
attribute in
xmlns
xmlns
namespace
function alters the namespace
variable.
$nm
option
227

Advertisement

Table of Contents
loading

This manual is also suitable for:

Junos os

Table of Contents