On Tue, 28 May 2002 [EMAIL PROTECTED] wrote:

> Hello, I would like to create CGI-like Perl scripts (mod_perl
> accelerated) that print XML.  I would probably populate the output using
> XML::Simple, or similar.  No, XSP is not what I want.  Yes, I've read
> all about it, and it's not exactly what I need. The article,
> "Introduction to AxKit" mentions this as a possibility, but I can't find
> any other docs on it. Thanks in advance, -Tech
>
   this is simular to the problems that i have ... i have have no desire
to port all my perl work and modules to another language. so i started on
a project of covnerting mod_perl cgi's over to produce xml and i want them
transformed into html ... i thought by axkit but it doesnt seem work as
far as i have seen.

   i also wanted to be able to do this all in 'baby steps' so if i couldnt
convert a script over i could wrap it in CDATA and let it be without
having to rewrite it.

   so in the end i basically converted all my mod_perl cgi's over to use
XML::Generator (sometimes just as a wrapper) and then i use XML::LibXSLT
and XML::LibXML with something like the following function to burn the
$xml->XML::Generator() data and a XSL/XPath stylesheet into HTML.

   the only thing i have problems with is some of the encoding of data
from time to time ... but i am sure everyone does. but thats why i like
the baby step method. if i didnt have a fallback i would be stuck with
trying to work things out in a whole new language (nearly). i cannot give
up my CGI.pm just quite yet.

sub transform($$) {
    my $xml_data=shift;
    my $xsl_data=shift;
    my $parser = XML::LibXML->new();
    my $xslt = XML::LibXSLT->new();
    $parser->keep_blanks(0);
    my $xml_data = $parser->parse_string($xml_data);
    my $xsl_data = $parser->parse_string($xsl_data);
    my $sh = $xslt->parse_stylesheet($xsl_data);
    my $html = $sh->transform($xml_data);
    my $str=$sh->output_string($html);
    return($str);
}

---
Gabriel Millerd |       "Be liberal in what you accept, and conservative
Plumber         |                      in what you send."
                |           -- Jon Postel, Internet Pioneer RFC1122


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to