MEAD

Query

Included libraries Package variables General documentation Methods

Package variables top
Privates (from my definitions)
$current_element_name;
$read_query_result;
$UTF_8_to_Big5 = Text::Iconv->new("UTF-8", "BIG5")
Included modulestop
Text::Iconv
XML::Parser
strict
Inherit top
Exporter
Synopsistop
No synopsis!
Descriptiontop
No description!
Methodstop
read_queryNo descriptionCode
read_query_handle_charNo descriptionCode
read_query_handle_startNo descriptionCode

Methods description


Methods code

read_querydescriptiontopprevnext
sub read_query {
    my $query_filename = shift;

    $read_query_result = {};

    my $xml_parser = new XML::Parser(Handlers => {
	Start =>\& read_query_handle_start,
	Char =>\& read_query_handle_char});

    open(UNICODE_VERSION, "iconv -f BIG5 -t UTF-8 $query_filename |");
    $xml_parser->parse(\*UNICODE_VERSION);
    close(UNICODE_VERSION);
    
    return $read_query_result;
}
read_query_handle_chardescriptiontopprevnext
sub read_query_handle_char {
    shift;
    my $text = shift;

    if ($text =~ /\S/) {
	$$read_query_result{$current_element_name} .=
	    $UTF_8_to_Big5->convert($text);
    }
}
read_query_handle_startdescriptiontopprevnext
sub read_query_handle_start {
    shift;
    my $element_name = shift;
    my %atts = @_;

    if ($element_name eq 'QUERY') {
	$$read_query_result{'QID'} = $atts{'QID'};
    }

    $current_element_name = $element_name;
}

General documentation

No general documentation available.