ActiveState XML-DOM 1.43

Ask a Question related to PERL Modules, Design and Development.

  1. #1

    Default ActiveState XML-DOM 1.43

    Hi, all,

    when it comes to parsing large files into something XML readable, a
    high amount of memory is required, and the CPU rate of the computer
    (even with 1 GB RAM) goes up to almost 100 %.
    Is there something like a switch or any other means to steer the
    memory behaviour of this module?

    Sincerely


    Markus Mohr

    P. S.:

    Here is some sample code of how I do parse my external file (one at a
    time). By this code, I parse an external file which is built up
    according to the CDA standard (Clinical Document Architecture). This
    file contains an uuencoded / uudecoded image object:

    #------------------------------------------------------------------------------#
    # Subroutine, um eine Anfrage in eine Patientenakte umzuwandeln
    #
    #------------------------------------------------------------------------------#
    sub import_anfrage ($$) {
    my ( $self, $anfrage, $konfiguration ) = @_;
    print "Die ANFRAGE wird imporiert:\n";
    print "---------------------------\n";

    open( TEMP, ">./anf_temp.anf" );
    print TEMP $anfrage;
    close TEMP;

    # Wir legen ein neues XML-Objekt an, das alte wird verworfen
    my $xml = CXML->new();
    $xml->construct_xml($konfiguration);
    $xml = $konfiguration->get_value('xml');
    my $xml_root = $xml->{'root'};

    # Die Anfrage wird in ein XML-Dokument geparst
    my $anfrage_parser = new XML::DOM::Parser( KeepCDATA => 1 );
    my $anfrage_doc = $anfrage_parser->parsefile("./anf_temp.anf");
    unlink("./anf_temp.anf");

    # Die Anfrage ist Teil der neuen EPA
    my $anfrage_root = $anfrage_doc->getElementsByTagName('ANFRAGE');
    $anfrage_root = $anfrage_root->item(0);
    $anfrage_root->setOwnerDocument( $xml->{'doc'} );
    my $nodes = $xml_root->getElementsByTagName('anfragen');
    my $node = $nodes->item(0);
    $node->appendChild($anfrage_root);

    # Anschliessend die Daten der Anfrage in die EPA übertragen
    foreach my $type (qw( PATIENT ARZT INSTITUTION UNTERSUCHUNG
    DIAGNOSE ANAMNESE MASSNAHME soziomedizinischedaten )) {
    my $anfrage = $xml_root->getElementsByTagName('ANFRAGE');
    $anfrage = $anfrage->item(0);
    for my $element ( $anfrage->getElementsByTagName($type) ) {
    my $destination_parent;
    SWITCH: for ($type) {
    /PATIENT/ && do { $destination_parent =
    'patient'; last; };
    /ARZT/ && do { $destination_parent =
    'arztliste'; last; };
    /INSTITUTION/ && do { $destination_parent =
    'paramedizinischeliste'; last; };
    /UNTERSUCHUNG/ && do { $destination_parent =
    'untersuchungen'; last; };
    /DIAGNOSE/ && do { $destination_parent =
    'diagnosen'; last; };
    /ANAMNESE/ && do { $destination_parent =
    'anamnesen'; last; };
    /MASSNAHME/ && do { $destination_parent =
    'massnahmen'; last; };

    #/soziomedi/ && do { $destination_parent =
    $xml_root; last; };
    }

    $destination_parent =
    $xml_root->getElementsByTagName($destination_parent);
    $destination_parent = $destination_parent->item(0);
    my $source = $element->cloneNode(1);

    $destination_parent = $xml_root if ( $type =~ /soziomed/
    );
    # print "Vorher:\n",
    $destination_parent->toString, "\n";
    print "TYPE: $type DP $destination_parent CT ",
    $source->toString, "\n";

    $destination_parent->appendChild($source);
    $destination_parent->removeChild(
    $destination_parent->getElementsByTagName('soziomedizinischedaten')->item(0)
    ) if ( $type =~ /soziomed/ );
    # print "\nJetzt:\n", $destination_parent->toString, "\n";

    # Bei den Daten des Patienten die alten (=leeren) Daten
    entfernen
    if ( $type eq 'PATIENT' ) {
    my $old_data = $destination_parent->getFirstChild;
    $destination_parent->removeChild($old_data);
    }

    # Altes Element aus der Anfrage entfernen
    my $source_parent = $element->getParentNode();
    $source_parent->removeChild($element);
    }
    }

    return;
    }

    Markus Mohr Guest

  2. Similar Questions and Discussions

    1. ppm.activestate.com down?
      just trying to install perl in my WinXP computer, trying to install some modules using PP3 and it gives me an error that it can't reach...
    2. PPM through Proxy (Activeperl / Activestate)
      hi, i have just installed the latest Activeperl from activestate.com and need to add some modules through PPM. I am behind a firewall and forced to...
    3. XML::RSS with ActiveState perl?
      Can you use the XML::RSS module with ActiveState perl? It doesn't seem to be in the ActiveState's package repository. Downloading XML::RSS from...
    4. cygwin or activestate ?
      Which is better perl setup on w98se: Full cygwin or activestate ? (or other) In particular I will probably be installing DBI +DBD and using...
    5. ActiveState 5.8.0 vs 5.8.1
      This may not have a difinitive answer. But will the modules I use for 5.8.0 work/be available with 5.8.1? Basically I am using HTML-Template and...
  3. #2

    Default Re: ActiveState XML-DOM 1.43

    On Fri, 04 Jun 2004 16:05:45 +0200, Markus Mohr
    <markus.mohr@mazimoi.de> wrote:
    >Hi, all,
    >
    >when it comes to parsing large files into something XML readable, a
    >high amount of memory is required, and the CPU rate of the computer
    >(even with 1 GB RAM) goes up to almost 100 %.
    >Is there something like a switch or any other means to steer the
    >memory behaviour of this module?
    >
    >Sincerely
    >
    >
    >Markus Mohr
    >
    >P. S.:
    >
    >Here is some sample code of how I do parse my external file (one at a
    >time). By this code, I parse an external file which is built up
    >according to the CDA standard (Clinical Document Architecture). This
    >file contains an uuencoded / uudecoded image object:
    >
    >#------------------------------------------------------------------------------#
    ># Subroutine, um eine Anfrage in eine Patientenakte umzuwandeln
    >#
    >#------------------------------------------------------------------------------#
    >sub import_anfrage ($$) {
    > my ( $self, $anfrage, $konfiguration ) = @_;
    > print "Die ANFRAGE wird imporiert:\n";
    > print "---------------------------\n";
    >
    > open( TEMP, ">./anf_temp.anf" );
    > print TEMP $anfrage;
    > close TEMP;
    >
    > # Wir legen ein neues XML-Objekt an, das alte wird verworfen
    > my $xml = CXML->new();
    > $xml->construct_xml($konfiguration);
    > $xml = $konfiguration->get_value('xml');
    > my $xml_root = $xml->{'root'};
    >
    > # Die Anfrage wird in ein XML-Dokument geparst
    > my $anfrage_parser = new XML::DOM::Parser( KeepCDATA => 1 );
    > my $anfrage_doc = $anfrage_parser->parsefile("./anf_temp.anf");
    > unlink("./anf_temp.anf");
    >
    > # Die Anfrage ist Teil der neuen EPA
    > my $anfrage_root = $anfrage_doc->getElementsByTagName('ANFRAGE');
    > $anfrage_root = $anfrage_root->item(0);
    > $anfrage_root->setOwnerDocument( $xml->{'doc'} );
    > my $nodes = $xml_root->getElementsByTagName('anfragen');
    > my $node = $nodes->item(0);
    > $node->appendChild($anfrage_root);
    >
    > # Anschliessend die Daten der Anfrage in die EPA übertragen
    > foreach my $type (qw( PATIENT ARZT INSTITUTION UNTERSUCHUNG
    >DIAGNOSE ANAMNESE MASSNAHME soziomedizinischedaten )) {
    > my $anfrage = $xml_root->getElementsByTagName('ANFRAGE');
    > $anfrage = $anfrage->item(0);
    > for my $element ( $anfrage->getElementsByTagName($type) ) {
    > my $destination_parent;
    > SWITCH: for ($type) {
    > /PATIENT/ && do { $destination_parent =
    >'patient'; last; };
    > /ARZT/ && do { $destination_parent =
    >'arztliste'; last; };
    > /INSTITUTION/ && do { $destination_parent =
    >'paramedizinischeliste'; last; };
    > /UNTERSUCHUNG/ && do { $destination_parent =
    >'untersuchungen'; last; };
    > /DIAGNOSE/ && do { $destination_parent =
    >'diagnosen'; last; };
    > /ANAMNESE/ && do { $destination_parent =
    >'anamnesen'; last; };
    > /MASSNAHME/ && do { $destination_parent =
    >'massnahmen'; last; };
    >
    > #/soziomedi/ && do { $destination_parent =
    >$xml_root; last; };
    > }
    >
    > $destination_parent =
    >$xml_root->getElementsByTagName($destination_parent);
    > $destination_parent = $destination_parent->item(0);
    > my $source = $element->cloneNode(1);
    >
    > $destination_parent = $xml_root if ( $type =~ /soziomed/
    >);
    > # print "Vorher:\n",
    >$destination_parent->toString, "\n";
    > print "TYPE: $type DP $destination_parent CT ",
    >$source->toString, "\n";
    >
    > $destination_parent->appendChild($source);
    > $destination_parent->removeChild(
    >$destination_parent->getElementsByTagName('soziomedizinischedaten')->item(0)
    >) if ( $type =~ /soziomed/ );
    > # print "\nJetzt:\n", $destination_parent->toString, "\n";
    >
    > # Bei den Daten des Patienten die alten (=leeren) Daten
    >entfernen
    > if ( $type eq 'PATIENT' ) {
    > my $old_data = $destination_parent->getFirstChild;
    > $destination_parent->removeChild($old_data);
    > }
    >
    > # Altes Element aus der Anfrage entfernen
    > my $source_parent = $element->getParentNode();
    > $source_parent->removeChild($element);
    > }
    > }
    >
    > return;
    >}

    Most probably there is also a problem with the concepts of puudecode
    and puuencode I use. They stem from the work of Andreas J. König in
    the underlying Convert::UU module, but seem to be very slow.

    Any idea how to prevent this slowness?

    Sincerely


    Markus Mohr
    Markus Mohr Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139