NAME

Spreadsheet::XLSX::Reader::LibXML::XMLReader - A LibXML::Reader xlsx base class

SYNOPSIS

	package MyPackage;
	use MooseX::StrictConstructor;
	use MooseX::HasDefaults::RO;
	extends	'Spreadsheet::XLSX::Reader::LibXML::XMLReader';
    

DESCRIPTION

This documentation is written to explain ways to use this module when writing your own excel parser. To use the general package for excel parsing out of the box please review the documentation for Workbooks, Worksheets, and Cells

This module provides a generic way to open an xml file or xml file handle and then extract information using the XML::LibXML::Reader parser. The additional methods and attributes are intended to provide some coalated parsing commands that are specifically useful in turning xml to perl data structures.

Attributes

Data passed to new when creating an instance. For modification of these attributes see the listed 'attribute methods'. For general information on attributes see Moose::Manual::Attributes. For ways to manage the instance when opened see the Methods.

file

Definition: This attribute holds the file handle for the file being read. If the full file name and path is passed to the attribute it is coerced to an IO::File file handle.

Default: no default - this must be provided to read a file

Required: yes

Range: any unencrypted xml file name and path or IO::File file handle

attribute methods Methods provided to adjust this attribute

set_file

Definition: change the file value in the attribute (this will reboot the file instance and lock the file)

get_file

Definition: Returns the file handle of the file even if a file name was passed

has_file

Definition: this is used to see if the file loaded correctly.

clear_file

Definition: this clears (and unlocks) the file handle

"Delegated Methods"

close

closes the file handle

workbook_inst

Definition: This attribute holds a reference to the top level workbook (parser). The purpose is to use some of the attributes stored there.

Default: no default

Required: not strictly but methods will fail without the delegated elements listed below. For information about the delegated methods see the links to the documentation. For hidden methods in indicator of where to look in the code is provded

Range: isa => 'Spreadsheet::XLSX::Reader::LibXML'

weak_ref => 1

attribute methods Methods provided to adjust this attribute

set_workbook_inst

set the attribute with a workbook instance

Delegated Methods (required) Methods delegated to this module by the attribute

error, set_error, clear_error => "error_inst" in Spreadsheet::XLSX::Reader::LibXML

get_empty_return_type => "empty_return_type" in Spreadsheet::XLSX::Reader::LibXML

get_sheet_name => "get_sheet_name" in Spreadsheet::XLSX::Reader::LibXML

sheet_count => "sheet_count" in Spreadsheet::XLSX::Reader::LibXML

_get_sheet_info, _get_rel_info, _get_id_info, _set_sheet_info, _get_workbook_file_type, _get_sheet_lookup => all hidden methods that accesss the hidden attribute _workbook_meta_data in the parser which delegates from Spreadsheet::XLSX::Reader::LibXML::WorkbookMetaInterface

xml_version

Definition: This stores the xml version stored in the xml header. It is read when the file handle is first set in this sheet.

Default: no default - this is auto read from the header

Required: no

Range: xml versions

attribute methods Methods provided to adjust this attribute

version

get the stored xml version

_clear_xml_version

clear the attribute value

_set_xml_version

set the attribute value

xml_encoding

Definition: This stores the data encoding of the xml file from the xml header. It is read when the file handle is first set in this sheet.

Default: no default - this is auto read from the header

Required: no

Range: valid xml file encoding

attribute methods Methods provided to adjust this attribute

encoding

get the attribute value

has_encoding

predicate for the attribute value

_clear_xml_encoding

clear the attribute value

_set_xml_encoding

set the attribute value

xml_header

Definition: This stores the xml header from the xml file. It is read when the file handle is first set in this sheet. I contains both the verion and the encoding where available

Default: no default - this is auto read from the header

Required: no

Range: valid xml file header

attribute methods Methods provided to adjust this attribute

get_header

get the attribute value

_set_xml_header

set the attribute value

position_index

Definition: This attribute is available to facilitate other consuming roles and classes. Of the attribute methods only the 'clear_location' method is used in this class during the 'start_the_file_over' method. It can be used for tracking same level positions with the same node name.

Default: no default - this is mostly managed by the child class or add on role

Required: no

Range: Integer

attribute methods Methods provided to adjust this attribute

where_am_i

get the attribute value

i_am_here

set the attribute value

clear_location

clear the attribute value

has_position

set the attribute value

file_type

Definition: This is a static attribute that shows the file type

Default: xml

attribute methods Methods provided to adjust this attribute

get_file_type

get the attribute value

Methods

These are the methods provided by this class only. They do not incude any methods added by roles to this class elsewhere

start_the_file_over

Definition: This will disconnect the XML::LibXML::Reader from the file handle, rewind the file handle, and then reconnect the XML::LibXML::Reader to the file handle.

Accepts: nothing

Returns: nothing

get_text_node

Definition: This will collect the text node at the current node position. It will return two items ( $success_or_failure, $text_node_value )

Accepts: nothing

Returns: ( $success_or_failure(1|undef), ($text_node_value|undef) )

get_attribute_hash_ref

Definition: Some nodes have attribute settings. This method returns a hashref with any attribute settings attached as key => value pairs or an empty hash for no attributes

Accepts: nothing

Returns: { attribute_1 => attribute_1_value ... etc. }

advance_element_position( [$node_name], [$number_of_times_to_index] )

Definition: This method will attempt to advance to $node_name (optional) or the next node if no $node_name is passed. If there is an expectation of multiple nodes of the same name at the same level you can also pass $number_of_times_to_index (optional). This will move through the xml file at the $node_name level the number of times indicated starting with wherever the xml file is already located. Meaning $number_of_times_to_index is a relative index not an absolute index.

Accepts: nothing

Returns: success or failure for the method call

location_status

Definition: This method gives three usefull location values with one call

Accepts: nothing

Returns: ( $node_depth (from the top of the file), $node_name, $node_type (xml numerical value for type) );

Delegated Methods

These are the methods delegated to this class from XML::LibXML::Reader. For more general parsing of subsections of the xml file also see Spreadsheet::XLSX::Reader::LibXML.

skip_siblings => "skipSiblings ()" in XML::LibXML::Reader

copy_current_node => "readOuterXml ()" in XML::LibXML::Reader

SUPPORT

github Spreadsheet::XLSX::Reader::LibXML/issues

TODO

1. Nothing currently

AUTHOR

Jed Lund
jandrew@cpan.org

COPYRIGHT

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

This software is copyrighted (c) 2014, 2015 by Jed Lund

DEPENDENCIES

XML::LibXML::Reader

SEE ALSO

Spreadsheet::ParseExcel - Excel 2003 and earlier

Spreadsheet::XLSX - 2007+

Spreadsheet::ParseXLSX - 2007+

Log::Shiras

All lines in this package that use Log::Shiras are commented out