The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

DTA::CAB::Format::XmlCommon - Datum parser|formatter: XML: base class

SYNOPSIS

use DTA::CAB::Format::XmlCommon;

##========================================================================
## Constructors etc.

$fmt = DTA::CAB::Format::XmlCommon->new(%args);
 
##========================================================================
## Methods: Input

$fmt = $fmt->close();
$fmt = $fmt->fromFile($filename_or_handle);
$fmt = $fmt->fromFh($filename_or_handle);
$fmt = $fmt->fromString($string);

##========================================================================
## Methods: Output

$fmt = $fmt->flush();
$fmt = $fmt->toString(\$str);
$fmt = $fmt->toFile($file);
$fmt = $fmt->toFh($fh);
$xmldoc = $fmt->xmlDocument();
$rootnode = $fmt->xmlRootNode();
$nod = $fmt->defaultXmlNode($value,\%opts);

DESCRIPTION

DTA::CAB::Format::XmlCommon is a base class for XML-formatters using XML::LibXML, and is not a fully functional format class by itself. See subclass documentation for details.

Globals

Variable: @ISA

DTA::CAB::Format::XmlCommon inherits from DTA::CAB::Format.

Constructors etc.

new
$fmt = CLASS_OR_OBJ->new(%args);

Constructor.

%args, %$fmt:

##-- input
xdoc => $xdoc,                          ##-- XML::LibXML::Document
xprs => $xprs,                          ##-- XML::LibXML parser
##
##-- output
encoding => $inputEncoding,             ##-- default: UTF-8; applies to output only!
level => $level,                        ##-- output formatting level (default=0)
##
##-- common
#(nothing here)

Methods: Persistence

noSaveKeys
@keys = $class_or_obj->noSaveKeys();

Override: returns list of keys not to be saved. Here, qw(xdoc xprs).

Methods: Input

close
$fmt = $fmt->close();

Override: close current input source.

fromFile
$fmt = $fmt->fromFile($filename_or_handle);

Override: select input from file.

fromFh
$fmt = $fmt->fromFh($fh);

Override: select input from filehandle $fh.

fromString
$fmt = $fmt->fromString($string);

Override: select input from string $string.

Methods: Output

flush
$fmt = $fmt->flush();

Override: flush accumulated output.

toString
$str = $fmt->toString();
$str = $fmt->toString($formatLevel);

Override: flush buffered output to byte-string. $formatLevel is passed to XML::LibXML::Document::toString(), and defaults to $fmt->{level}.

toFh
$fmt_or_undef = $fmt->toFh($fh,$formatLevel);

Override: flush buffered output document to filehandle $fh.

xmlDocument
$xmldoc = $fmt->xmlDocument();

Returns output buffer $fmt->{xdoc}, creating it if not yet defined.

xmlRootNode
$rootnode = $fmt->xmlRootNode();
$rootnode = $fmt->xmlRootNode($nodname);

Returns output buffer root node, creating one if not yet defined.

$nodname is the name of the root node to create (if required); default='doc'.

putToken

Not implemented here.

putSentence

Not implemented here.

putDocument

Not implemented here.

defaultXmlNode
$nod = $fmt->defaultXmlNode($value,\%opts);

Default XML node generator, which creates very perl-ish XML.

%opts is unused.

AUTHOR

Bryan Jurish <moocow@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2009-2019 by Bryan Jurish

This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.24.1 or, at your option, any later version of Perl 5 you may have available.