logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

POE::Filter::XML::Handler - Default SAX Handler for POE::Filter::XML

Author

       Nicholas R. Perez <nperez@cpan.org>

Description

       POE::Filter::XML::Handler is the default SAX handler for POE::Filter::XML. It extends XML::SAX::Base to
       provide different semantics for streaming vs.  non-streaming contexts. This handle by default builds
       POE::Filter::XML::Nodes.

Name

       POE::Filter::XML::Handler - Default SAX Handler for POE::Filter::XML

Private_Attributes

current_node
           is: rw, isa: POE::Filter::XML::Node

       current_node holds the node being immediately parsed.

   finished_nodes
           is: ro, isa: ArrayRef, traits: Array

       finished_nodes holds the nodes that have been completely parsed. Access to this attribute is provided
       through the following methods:

           handles =>
           {
               all_finished_nodes => 'elements',
               has_finished_nodes => 'count',
               add_finished_node => 'push',
               get_finished_node => 'shift',
           }

   depth_stack
           is: ro, isa: ArrayRef, traits: Array

       depth_stack holds the operating stack for the parsed nodes. As nodes are processed, ancendants of the
       current node are stored in the stack. When done they are popped off the stack. Access to this attribute
       is provided through the following methods:

           handles =>
           {
               push_depth_stack => 'push',
               pop_depth_stack => 'pop',
               depth => 'count',
           }

Protected_Methods

overridestart_element
           (HashRef $data)

       start_element is overridden from the XML::SAX::Base class to provide our custom behavior for dealing with
       streaming vs. non-streaming data. It builds Nodes then attaches them to either the root node (non-
       streaming) or as stand-alone top level fragments (streaming) sets them to the current node. Children
       nodes are appended to their parents before getting set as the current node. Then the base class method is
       called via super()overrideend_element
           (HashRef $data)

       end_element is overridden from the XML::SAX::Base class to provide our custom behavior for dealing with
       streaming vs. non-streaming data. Mostly this method is in charge of stack management when the depth of
       the stack reaches certain points. In streaming documents, this means that top level fragments (not root)
       are popped off the stack and added to the finished_nodes collection. Otherwise a Node is created with
       stream_end set and added to the finished nodes.

       Then the base class method is called via super()overridecharacters
           (HashRef $data)

       characters merely applies the character data as text to the current node being processed. It then calls
       the base class method via super().

Public_Attributes

not_streaming
           is: ro, isa: Bool, default: false

       not_streaming determines the behavior for the opening tag parsed. If what is being parsed is not a
       stream, the document will be parsed in full then placed into the finished_nodes attribute. Otherwise, the
       opening tag will be placed immediately into the finished_nodes bucket.

Public_Methods

reset
       reset will clear the current node, the finished nodes, and the depth stack.

Version

       version 1.140700

See Also