.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "DumpXML 3pm" .TH DumpXML 3pm "2016-12-16" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Data::DumpXML \- Dump arbitrary data structures as XML .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use Data::DumpXML qw(dump_xml); \& $xml = dump_xml(@list) .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module provides a single function called \fIdump_xml()\fR that takes a list of Perl values as its argument and produces a string as its result. The string returned is an \s-1XML\s0 document that represents any Perl data structures passed to the function. Reference loops are handled correctly. .PP The following data model is used: .PP .Vb 5 \& data : scalar* \& scalar = undef | str | ref | alias \& ref : scalar | array | hash | glob | code \& array: scalar* \& hash: (key scalar)* .Ve .PP The distribution comes with an \s-1XML\s0 schema and a \s-1DTD\s0 that more formally describe this structure. .PP As an example of the \s-1XML\s0 documents produced, the following call: .PP .Vb 2 \& $a = bless [1,2], "Foo"; \& dump_xml($a); .Ve .PP produces: .PP .Vb 9 \& \& \& \& \& 1 \& 2 \& \& \& .Ve .PP If \fIdump_xml()\fR is called in a void context, then the dump is printed on \s-1STDERR\s0 automatically. For compatibility with \f(CW\*(C`Data::Dump\*(C'\fR, there is also an alias for \fIdump_xml()\fR called simply \fIdump()\fR. .PP \&\f(CW\*(C`Data::DumpXML::Parser\*(C'\fR is a class that can restore data structures dumped by \fIdump_xml()\fR. .SS "Configuration variables" .IX Subsection "Configuration variables" The generated \s-1XML\s0 is influenced by a set of configuration variables. If you modify them, then it is a good idea to localize the effect. For example: .PP .Vb 5 \& sub my_dump_xml { \& local $Data::DumpXML::INDENT = ""; \& local $Data::DumpXML::XML_DECL = 0; \& local $Data::DumpXML::DTD_LOCATION = ""; \& local $Data::DumpXML::NS_PREFIX = "dumpxml"; \& \& return dump_xml(@_); \& } .Ve .PP The variables are: .ie n .IP "$Data::DumpXML::INDENT" 4 .el .IP "\f(CW$Data::DumpXML::INDENT\fR" 4 .IX Item "$Data::DumpXML::INDENT" You can set the variable \f(CW$Data::DumpXML::INDENT\fR to control the amount of indenting. The variable contains the whitespace you want to be used for each level of indenting. The default is a single space. To suppress indenting, set it to "". .ie n .IP "$Data::DumpXML::INDENT_STYLE" 4 .el .IP "\f(CW$Data::DumpXML::INDENT_STYLE\fR" 4 .IX Item "$Data::DumpXML::INDENT_STYLE" This variable controls where end element are placed. If you set this variable to the value \*(L"Lisp\*(R" then end tags are not prefixed by \s-1NL.\s0 This give a more compact output. .ie n .IP "$Data::DumpXML::XML_DECL" 4 .el .IP "\f(CW$Data::DumpXML::XML_DECL\fR" 4 .IX Item "$Data::DumpXML::XML_DECL" This boolean variable controls whether an \s-1XML\s0 declaration should be prefixed to the output. The \s-1XML\s0 declaration is the thingy. The default is 1. Set this value to 0 to suppress the declaration. .ie n .IP "$Data::DumpXML::NAMESPACE" 4 .el .IP "\f(CW$Data::DumpXML::NAMESPACE\fR" 4 .IX Item "$Data::DumpXML::NAMESPACE" This variable contains the namespace used for the \s-1XML\s0 elements. The default is to let this be a \s-1URI\s0 that actually resolve to the \s-1XML\s0 schema on \s-1CPAN. \s0 Set it to "" to disable use of namespaces. .ie n .IP "$Data::DumpXML::NS_PREFIX" 4 .el .IP "\f(CW$Data::DumpXML::NS_PREFIX\fR" 4 .IX Item "$Data::DumpXML::NS_PREFIX" This variable contains the namespace prefix to use on the elements. The default is "", which means that a default namespace will be declared. .ie n .IP "$Data::DumpXML::SCHEMA_LOCATION" 4 .el .IP "\f(CW$Data::DumpXML::SCHEMA_LOCATION\fR" 4 .IX Item "$Data::DumpXML::SCHEMA_LOCATION" This variable contains the location of the \s-1XML\s0 schema. If this variable is non-empty, then an \f(CW\*(C`xsi:schemaLocation\*(C'\fR attribute is added to the top level \f(CW\*(C`data\*(C'\fR element. The default is not to include this, as the location can be inferred from the default \s-1XML\s0 namespace used. .ie n .IP "$Data::DumpXML::DTD_LOCATION" 4 .el .IP "\f(CW$Data::DumpXML::DTD_LOCATION\fR" 4 .IX Item "$Data::DumpXML::DTD_LOCATION" This variable contains the location of the \s-1DTD. \s0 If this variable is non-empty, then a is included in the output. The default is to point to the \s-1DTD\s0 on \s-1CPAN. \s0 Set it to "" to suppress the line. .SH "BUGS" .IX Header "BUGS" Class names with 8\-bit characters are dumped as Latin\-1, but converted to \s-1UTF\-8\s0 when restored by the Data::DumpXML::Parser. .PP The content of globs and subroutines are not dumped. They are restored as the strings \*(L"** glob **\*(R" and \*(L"** code **\*(R". .PP \&\s-1LVALUE\s0 and \s-1IO\s0 objects are not dumped at all. They simply disappear from the restored data structure. .SH "SEE ALSO" .IX Header "SEE ALSO" Data::DumpXML::Parser, XML::Parser, XML::Dumper, Data::Dump .SH "AUTHORS" .IX Header "AUTHORS" The \f(CW\*(C`Data::DumpXML\*(C'\fR module is written by Gisle Aas , based on \f(CW\*(C`Data::Dump\*(C'\fR. .PP The \f(CW\*(C`Data::Dump\*(C'\fR module was written by Gisle Aas, based on \&\f(CW\*(C`Data::Dumper\*(C'\fR by Gurusamy Sarathy . .PP .Vb 2 \& Copyright 1998\-2003 Gisle Aas. \& Copyright 1996\-1998 Gurusamy Sarathy. .Ve .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.