Kvasir::Loader::XML(3)User Contributed Perl DocumentationKvasir::Loader::XML(3) NNAAMMEE Kvasir::Loader::XML - Load Kvasir engine declarations in XML SSYYNNOOPPSSIISS use Kvasir::Loader::XML; my $engine = Kvasir::Loader::XML->load_file("my_engine.xml"); $engine->run(); my $other_engine = Kvasir::Loader::XML->load_string($xml); $other_engine->run(); DDEESSCCRRIIPPTTIIOONN This module provides a mean to load Kvasir engine declarations from XML. IINNTTEERRFFAACCEE CCLLAASSSS MMEETTHHOODDSS load_file ( PATH ) Loads the engine declaration from _P_A_T_H. load_string ( XML ) Loads the engine declaration from _X_M_L. XXMMLL DDooccuummeenntt ssttrruuccttuurree The document root element must be <>. Valid children are: +o <> - Declares an action. +o <> - Declares an input. +o <> - Declares an output. +o <> - Declares a rule. +o <> - Groups a set of rules under a common name. +o <> - Connects a set of rules to an action. AAccttiioonn,, IInnppuutt,, OOuuttppuutt aanndd RRuullee eelleemmeennttss The elements <>, <>, <> and <> all have the fol- lowing mandatory attributes: name The name of the entity to define in the engine. instanceOf The class that implements the entity and that'll be instansiated when the engine is runned. If the class defined by _i_n_s_t_a_n_c_e_O_f implements the method "process_xml_loader_args" it will be called as a class method with the "XML::LibXML::Element"-element as only argument. This method must return a list of arguments that will be passed to the constructor for the class when the entity is instansiated. If no "process_xml_loader_args" method is available the loader will interpret all children as a hash where the elements name is the key and its text content its value. If a child is an empty element, that is has no children (as in "") its value will be undef. This hash will be passed to the constructor as a hash reference. RRuulleesseettss By using the tag <> it is possible to give a set of rules a shared name that can later be used when binding together rules and actions. The attribute _n_a_m_e is always expected and is used to give the ruleset its name which can be referenced later on by other rulesets or rule<->action mappings. To specify what rules to include it expects <>nnaammee ooff rruullee<>nnaammee ooff rruulleesseett<> elements as children. Any other element will result in an error. In addition to specifying specific rules or contens of other rulesets it is also possible to include the rules that matches the criteria specified by the attributes: rulesMatchingName Include all rules that matches the name by the given Perl5 regular expression. rulesOfClass Include all rules which inherits from the given class. Note, if both attributes above are present it does not create a ruleset with the rule that matches both (i.e a union). CCoonnnneeccttiinngg rruulleess aanndd aaccttiioonnss To connect an action to a rule use the <> element. It expects the attribute _a_c_t_i_o_n which must be the name of an already defined action. Which rules to invoke the action on is specified with children of type <>nnaammee ooff rruullee<>nnaammee ooff rruulleesseett<>. Any other element will result in an error. SSEEEE AALLSSOO Kvasir BBUUGGSS AANNDD LLIIMMIITTAATTIIOONNSS Please report any bugs or feature requests to "bug-kvasir-loader-xml@rt.cpan.org", or through the web interface at . AAUUTTHHOORR Claes Jakobsson "" LLIICCEENNCCEE AANNDD CCOOPPYYRRIIGGHHTT Copyright (c) 2007, Versed Solutions "". All rights reserved. This software is released under the MIT license cited below. TThhee ""MMIITT"" LLiicceennssee Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Soft- ware"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MER- CHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFT- WARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. perl v5.8.6 2007-10-01 Kvasir::Loader::XML(3)