NAME

    XML::DT - a package for down translation of XML to strings


SYNOPSIS

    use XML::DT;

    %xml=( 'music'    => sub{"Music from: $c\n"},
           'lyrics'   => sub{"Lyrics from:$c\n (the value of attribute
                               IN is:$v{IN}\n)"},
           'title'    => sub{ uc($c) },
           '-default' => sub{"$q:$c"},
           '-outputenc' => 'ISO-8859-1');
    
    print dt($filename,%xml);

    print dtstring("<arq>
                    <title>Vejam Bem</title>
                    <music>Zeca Afonso</music>
                    </arq>",%xml);

    inctxt('music/lyrics')
    inctxt('music.*')


DESCRIPTION

This module processes XML files with an approach similar to OMNIMARC.

Down translation function dt receives a filename and a set of expressions (functions) defining the processing and associated values for each element.

dtstring is similar but takes input from a string instead of a file.


inctxt function

inctxt(pattern) is true if the actual element path matches the provided pattern. This function is ment to be used in the element functions in order to achive context dependent processing.


User provided element processing functions

The user must provide an HASH with a function for each element, that computes element output. Functions can use the element name $q, the element content $c and the atribute values hash %v.

All those global variables are defined in $main::.

Each time an element is find the associated function is called.

Content is calculated by concatenation of element contents strings and interior elements return values.


-default function

When a element has no associated function, the function associated with -default called. If no -default function is defined the default function returns a XML like string for the elemente.


-outputenc option

-outputenc defines the output encoding (default is Unicode UTF8).


-inputenc option

-inputenc forces a input encoding type. Whenever that is possible, define the input encoding in the XML file:

   <?xml version='1.0' encoding='ISO-8859-1'?>


-pcdata function

-pcdata function is used to define tranformation over the contents. Typically this function should look at context (see inctxt function)

The default -pcdata function is the identity


-begin function

function to be executed before processing XML file.

Example of use: inicialization of sife-effect variables


-end function

function to be executed after processing XML file. I can use $c content value. The value returned by -end will be the dt return value.

Example of use: post-processing of returned contents


BUGS

The global variables $q %v $c are defined in main. So you may have to write $::c ... if you are outside main.


Author

Jose Joao, jj@di.uminho.pt

   http://www.di.uminho.pt/~jj/perl/XML/


NAME

lat1.pm - module for unicode utf8 -> latin1 translation of strings


SYNOPSIS

   $latin1string = lat1::utf8($utf8string)