Module XMLparser :: Class XMLparser
[hide private]
[frames] | no frames]

Class XMLparser

source code

This module recursively parses an XML map file looking for supported xml tags. These tags contain metadata about an HDF object in an HDF file. If a supported tag is found the class creates an instance of "HDFhandler", this class will load the HDF file and return the object data in a normalized buffer.

This buffer and the xml tag are passed then to the handler class(in this iteration just VData). The handler classes are in charge of reconstruct the HDF objects and return them as Python data structures.

Instance Methods [hide private]
 
__init__(self, hdf_path, map_file, operation, hdf_object, dump_format)
Constructor:
source code
 
parseXML(self)
It parses the XML map file using the ElementTree API in a recursive function call "recursiveWalk".
source code
 
recursiveWalk(self, node, depth)
This recursive function traverse the XML document using the ElementTree API; all the nodes are stored in a tree-like structure.
source code
Method Details [hide private]

__init__(self, hdf_path, map_file, operation, hdf_object, dump_format)
(Constructor)

source code 

Constructor:

Initialize the internal variables.

XMLfile: Name of the XML map file from the command line argument. self.tree: An ElementTree instance, loads XML documents in a tree structure. self.group_stack: Stack of group names later used to name the output files.

recursiveWalk(self, node, depth)

source code 

This recursive function traverse the XML document using the ElementTree API; all the nodes are stored in a tree-like structure. If a tag is recognized the method uses "self.operation" to either print a short version of the XML file or extract the object into to a CSV file.

If a 'Group' tag is found, the attribute 'ID' is inserted in a stack; its children will have this value as prefix for the file name. This is accumulative, if a given VData object is under the group ID_ABC and ID_DEF the CSV file will be named: G-ID_ABC-G-ID_DEF.csv