The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

BPM::Engine::Util::XPDL - XPDL parsing helper functions

VERSION

0.01

SYNOPSIS

use BPM::Engine::Util::XPDL ':all';

$data = xpdl_hash($input);

say $data->{WorkflowProcesses}->[0]->{Id};

DESCRIPTION

This module provides helper functions for parsing of XPDL files and strings.

Parameter INPUT

The first parameter to any function should be the XML message to be translated into a Perl structure. Choose one of the following:

A filename or URL

If the filename contains no directory components, the function will look for the file in the current directory.

$ref = xpdl_hash('/etc/params.xml');

Note, the filename - (dash) can be used to parse from STDIN.

A scalar reference to an XML string

A string containing XML will be parsed directly.

my $string = '<Some>Thing</Some>';
$doc = xml_doc(\$string);
An IO::Handle object

An IO::Handle object will be read to EOF and its contents parsed. eg:

$fh  = IO::File->new('./xpdl/workflows.xpdl');
$doc = xml_doc($fh);

EXPORTS

None of the functions are exported by default. The :all key exports all functions.

xpdl_hash

my $data = xpdl_hash($input);
say $data->{WorkflowProcesses}->[0]->{Id};

The result of xpdl_doc() parsed into a hash by BPM::XPDL. The resulting data hash represents the XPDL document.

This is presumably the only function you'll need from this module.

xml_hash

my $data = xml_hash($input);
say $data->{WorkflowProcesses}->[0]->{Id};

A 'lightweight' parsing of XPDL-like XML strings. Useful for testing. Example:

my $string = qq!
<Package>
<WorkflowProcesses>
    <WorkflowProcess Id="OrderPizza" Name="Order Pizza">
        <Activities>
            <Activity Id="PlaceOrder" />
            <Activity Id="WaitForDelivery" />
            <Activity Id="PayPizzaGuy" />
        </Activities>
        <Transitions>
            <Transition Id="1" From="PlaceOrder" To="WaitForDelivery"/>
            <Transition Id="2" From="WaitForDelivery" To="PayPizzaGuy"/>
        </Transitions>
    </WorkflowProcess>
</WorkflowProcesses>
</Package>!;

my $data = xml_hash($string);

say $data->{WorkflowProcesses}->[0]->{Id}; # prints 'OrderPizza'

This function will possibly be deprecated in the near future.

xml_doc

$doc = xml_doc($input);

Parses the given file (or URL), string, or input stream into a DOM tree.

Returns a XML::LibXML::Document object.

xpdl_doc

Parses the given file (or URL), string, or input stream (by calling xml_doc()) and does some checks on the document, specifically:

  • Verify that the XPDL version in the document is supported;

  • Clean up modeler-proprietary elements and attributes for XPDL generated by the http://bizagi.com.

  • Validate the document against the XPDL schema

Returns a XML::LibXML::Document object.

DEPENDENCIES

AUTHOR

Peter de Vos <sitetech@cpan.org>

COPYRIGHT AND LICENSE

Copyright (c) 2010, 2011 Peter de Vos <sitetech@cpan.org>.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 348:

alternative text 'http://bizagi.com' contains non-escaped | or /