The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Wombat::Util::XmlMapper - xml file parser

SYNOPSIS

  my $mapper = Wombat::Util::XmlMapper->new();
  $mapper->setValidating(1);

  $mapper->addRule('Server', $mapper->objectCreate('Wombat::Core::Server'));
  $mapper->addRule('Server', $mapper->setProperties());

DESCRIPTION

Configures a set of actions to take while parsing an XML file.

CONSTRUCTOR

new()

Create and return an instance, initializing fields to default values.

PUBLIC METHODS

addRule($xpath, $action)

Add a rule that specifies an action to be taken for each node with the given xpath.

objectCreate($class, [$attribute])

Return an action that creates an object and adds it to the stack. If an attribute is specified, that attribute's value will be used as the class name; otherwise the specified class will be defaulted to.

setProperties()

Return an action that calls a property setter method on the object at the top of the stack for each attribute in the curent element.

addChild($method)

Return an action that uses the named method to add the object at the top the stack as a child of the object just below it in the stack.

methodSetter($method, [$num])

Return an action that calls the named method on the object at the top of the stack. Method parameters are taken from the specified number of sub-elements of the current element, or from the body of the current element if 0 sub-elements are specified.

methodParam($index, [$attribute])

Return an action that extracts the value for the named attribute on the current element, or the body of the current element if no attribute is provided, and sets it in the array at the top of the stack ath tindicated index. Use this method to accumulate parameter values for a previously called methodSetter() action.

readXml($fh. [$root])

Read and parse an XML stream and perform all configured actions. Return the root of the generated object hierarchy, optionally using the provided root object.

SEE ALSO

Wombat::Util::XmlAction

AUTHOR

Brian Moseley, bcm@maz.org