NAME
Spreadsheet::XLSX::Reader::LibXML::XMLReader - XLSX - LibXML Reader base class
SYNOPSIS
package MyPackage;
use MooseX::StrictConstructor;
use MooseX::HasDefaults::RO;
extends 'Spreadsheet::XLSX::Reader::LibXML::XMLReader';
DESCRIPTION
XML::LibXML supports TIMTOWDI by providing multiple ways to parse a file. This package is built to support general pull parsing using XML::LibXML::XMLReader. All specific pull parsers are built on this. If you want to use this to write your own reader just load the file name and use the methods to explore the file. Since this is a pull parser you have to rewind to the beginning to go back.
This sheet has the role Spreadsheet::XLSX::Reader::::LibXML::LogSpace and all it's functionality added.
Attributes
Data passed to new when creating an instance (pull_parser). For modification of these attributes see the listed Methods of the instance. All role attributes and methods are documented in the role documentation.
file_name
Definition: This is the file to be read using XML::LibXML::Reader techniques.
Default none
Range any complete file name
error_inst
Definition: This package can share a single error instance so that an error registered in one place can be read in another place. The documentation for the instance is found in Spreadsheet::XLSX::Reader::Error
Default none
Range InstanceOf[ 'Spreadsheet::XLSX::Reader::LibXML::Error' ]
Methods
These include methods to adjust attributes as well as providing methods to navigate the file.
get_system_type
Definition: This is the way to see whether the conversion is Windows or Apple based
Accepts:Nothing
Returns: win_excel|apple_excel
_load_unique_bits
Definition: _load_unique_bits isn't a function with and inner() call in it. I could never get Moose to call inner() in a trigger function and I'm sure there is good theory behind not doinng it. However, when the file is loaded to the parser there may be elements of the file that are not found in the _core_element(s) and should be loaded in the subclass for reference. When this class loads the file and checks if the subclass has a _load_unique_bits function. The subclass can then load any relevent data to the instance that is unique to the subclass. The subclass function _load_unique_bits is expected to either return undef|0 or '1'. Returning '1' will force the file to reload. This is useful when the _load_unique_bits function in the sublclass needs to iterate through the _core_elements section to find non-core data. For the reader to then not be lost it needs to reset at the beginning of the file. The relevant section in this class looks like this:
my $reload = 0;
if( !$mapped and $self->can( '_load_unique_bits' ) ){
###LogSD Loading unique bits
$reload = $self->_load_unique_bits( $reader, $encoding );
}
if( !$reload ){
###LogSD All ready
}elsif( $reload == 1 ){
$reader = XML::LibXML::Reader::LibXML->new( location => $self->get_file_name );
}else{
return undef;
}
ATTRIBUTES
Data passed to new when creating an instance (parser). For modification of these attributes see the listed "METHODS" of the instance.
file_name
Definition: This attribute stores the string used to access the file (the file name). It will be tested as an XMLFile type.
Default none
Range any readable xml file (null not allowed)
METHODS
These include methods to adjust attributes as well as providing methods to implement the functionality of the module.
get_position( $int )
Definition: This calls a routine that searches for the identified position of the defined _core_element in the xml file. If no value is passed it will test for the current recorded position and pull the next one.
Accepts: an integer representing the position in the array of elements indicated by the attribute _core_element. It will calculate the next position if no value is passed.
Returns: An XML::LibXML::Element instance with the element data from the file contained in it. If the requested position (or the next position) is passed the end of the file then this returns undef.
error( $error_string )
Definition: This method is handled from the workbook link generally built by Spreadsheet::XLSX::Reader::LibXML. See Spreadsheet::XLSX::Reader::LibXML::Error for details of the error_string attribute associated with this method.
Accepts: a message string
Returns: nothing
encoding
Definition: This is the encoding of the file as recorded in the xml attribute. In general XML::LibXML should be converting the data into unicode for perl..
Accepts: nothing
Returns: the value of the encoding attribute in the xml file
where_am_i
Definition: The module tracks the last recorded _core_element position returned. This is the way to read that value.
Accepts: nothing
Returns: An integer counting from 0 of the last _core_element returned
has_position
Definition: Either before the first position is returned or after the end of the _core_element list is reached the last recorded position will be undef. This is a way to test for that state.
Accepts: nothing
Returns: a boolean value indicating if there is a current _core_element position.
SUPPORT
TODO
1. Nothing yet
AUTHOR
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 by Jed Lund