Re: SAX-J and the DPH (DJH?)

Sean Mc Grath (digitome@iol.ie)
Wed, 31 Dec 1997 18:56:39 GMT


So this works if:

1) No more than 1 telephone number per line [Chris]
2) No cdata marked sections [Chris]
3) The attribute value literal for client does not have any entity
references [Sean - suggested]
4) The target telephone number does not contain entity references [Sean -
suggested ]
5) appendix elements do not nest [Sean - suggested]
6) Telephone numbers do not nest (problem if regexp matching is greedy)
[Sean - suggested]

Others? I think a little list of "gotchas" like this would find the way
onto many a DPH's wall (including mine!).

[Chris Maden]
>
>$inappendix = FALSE;
>
>while (<>) {
> if (/<appendix/) {
> $inappendix = TRUE;
> }
> if (/<\/appendix/) {
> $inappendix = FALSE;
> }
> if ((/^(.*<telephone[^>]*>)555-1234(.*)$/) && $inappendix) {
> $pre = $1;
> $post = $2;
> if (!(/client\s*=\s*["']Jones["']/)) {
> print $pre . "555-4321" . $post . "\n";
> }
> else {
> print $_;
> }
> }
> else {
> print $_;
> }
>}
>
>
Sean Mc Grath
sean at digitome dot com