[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Po4a-dev]Help needed to fix a problem in module sgml
From: |
Martin Quinson |
Subject: |
[Po4a-dev]Help needed to fix a problem in module sgml |
Date: |
Mon, 17 Feb 2003 14:56:29 +0100 |
User-agent: |
Mutt/1.5.3i |
Hello,
I have a problem in the SGML module which I fail to solve alone.
In order to handle the inclusion entities, I build a temp file and then
parse this constructed temp file. In this file, each file inclusion entitie
is replaced by the file itself.
The code for that is the following:
# Protect &entities; (but the ones asking for a file inclusion)
# search the file inclusion entities
my %entincl;
my $searchprolog=$prolog;
while ($searchprolog =~ /<!ENTITY\s(\S*)\s*SYSTEM\s*"([^>"]*)">(.*)$/is)
{#})"{
print STDERR "Seen the entity of inclusion $1 (=$2)\n"
if ($debug{'entities'});
$entincl{$1}=$2;
$searchprolog = $3;
}
# Change the entities to their content
foreach my $key (keys %entincl) {
print STDERR "read ".$entincl{$key}."\n" if ($debug{'entities'});
open IN,"<".$entincl{$key} ||
die sprintf(gettext("Can't open %s: %s\n"),$entincl{$key},$!);
local $/ = undef;
$entincl{$key} = <IN>;
close IN;
}
# Change the entities
while ($origfile =~ /^(.*?)&([^;\s]*);(.*)$/s) {
if (defined $entincl{$2}) {
$origfile = "$1".$entincl{$2}."$3";
print STDERR "substitute $2\n" if ($debug{'entities'});
} else {
$origfile = "$1".'{PO4A-amp}'."$2;$3";
print STDERR "preserve $2\n" if ($debug{'entities'});
}
}
The problem is that afterward, the position (filename and line number) are
naturally wrong. My problem is the design of a solution to fix those values
afterward.
When using, i know the line number in the rewritten file, and I need to
build a data structure during the code above which can allow me to retrieve
the real file and line number from that.
Any idea is welcome. Patches are VERY welcome ;)
Thanks, Mt.
--
Source is provided to this software because we believe users have the right
to know exactly what a program is going to do before they run it.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Po4a-dev]Help needed to fix a problem in module sgml,
Martin Quinson <=