Kernel::GenericInterface::Mapping::XSLT

NAME

Kernel::GenericInterface::Mapping::XSLT – GenericInterface XSLT data mapping backend

PUBLIC INTERFACE

has DebuggerObject

Attribute that holds the debugger object.

has MappingConfig

Attribute that holds the mapping config.

has XMLin

Attribute that holds XMLin options.

new()

usually, you want to create an instance of this by using Kernel::GenericInterface::Mapping->new();

Map()

Provides mapping based on XSLT style sheets. Additional data is provided by the function results from various stages in requester and provider. This data can be included in the XSLT mapping as 'DataInclude' structure via configuration.

    my $ReturnData = $MappingObject->Map(
        Data => {
            'original_key' => 'original_value',
            'another_key'  => 'next_value',
        },
        DataInclude => {
            RequesterRequestInput => { ... },
            RequesterRequestPrepareOutput => { ... },
            RequesterRequestMapOutput => { ... },
            RequesterResponseInput => { ... },
            RequesterResponseHeaders => { ... },
            RequesterResponseMapOutput => { ... },
            RequesterErrorHandlingOutput => { ... },
            ProviderRequestInput => { ... },
            ProviderRequestMapOutput => { ... },
            ProviderResponseInput => { ... },
            ProviderResponseMapOutput => { ... },
            ProviderErrorHandlingOutput => { ... },
        },
        Force => 1 # optional, force map to run even if no 'Data' was passed.
    );

    my $ReturnData = {
        'changed_key'          => 'changed_value',
        'original_key'         => 'another_changed_value',
        'another_original_key' => 'default_value',
        'default_key'          => 'changed_value',
    };

PRIVATE INTERFACE

_NormalizeData()

Convert any value nested within the payload, whether it's in a simple or complex structure. This conversion is managed by the provided Search parameter, which must be a compiled regular expression with a capturing group. This capturing group serves as the input for the Replace? parameter, a Perl function used in the replacement part of a substitution regular expression.

After the replacement, the resulting string can be enclosed within another string using the Enclose parameter, which is also a Perl function that takes the replaced string as input.

    my $Data = {
        Key1 => {
            SubKey1 => [
                'MyTest',
                # ...
            ],
            # ...
        },
        Key2 => 'Value',
        # ...
    },

    my $Result = $MappingObject->_NormalizeData(
        Data => $Data,
        Search  => qr{ (s) }x,
        Replace => sub { return uc shift },
        Enclose => sub { return '--Start--' . shift . '--End--'; },
    );

converts to:

    $Data = {
        Key1 => {
            SubKey1 => [
                '--Start-MyTeSt--End--',    # Notice the capital 'S'
                # ...
            ],
            # ...
        },
        Key2 => 'Value',
        # ...
    };

returns:

    $Result => {
        Success = 1;    # or log object;
    }

Note: This function updated the Data parameter reference, it does not return the value, so Data must be passed as reference so the modification can be applies outside the function.

Scroll to Top