##
##  wml::fmt::xtable - HTML tables through Advanced Syntax
##  Copyright (c) 1997-2001 Ralf S. Engelschall, All Rights Reserved. 
##

#use wml::std::tags

<set-var __xtable:level=0 />
<define-tag xtable endtag=required>
<increment __xtable:level />
<perl filehandle="FH_XTABLE">
{
    my $tmpfile = "$(WML_TMPDIR)/wml.table.$$.tmp";
    my $options;
    <perl:assign $options>%attributes</perl:assign>;
    <when <eq <get-var __xtable:level /> 1 />>
    local *FH_XTABLE;
    open(FH_XTABLE, ">$tmpfile");
    </when>
    <perl:assign>
      <wwwtable $options>
        %body
      </wwwtable>
    </perl:assign>
</perl>
#   we cut here to change filehandle
<perl>
    <when <eq <get-var __xtable:level /> 1 />>
    print FH_XTABLE <perl:var />;
    close(FH_XTABLE);
    open(FH_XTABLE_IN,
       "$(WML_LOC_LIBDIR)/exec/wml_aux_freetable $tmpfile < /dev/null |");
    local ($/) = undef;
    <perl:var /> = <*FH_XTABLE_IN>;
    close(FH_XTABLE_IN);
    <perl:print:var />
    unlink("$tmpfile");
    </when>
}
</perl>
<decrement __xtable:level />
</define-tag>

##EOF##
