Hi,
I was wrong at one point in my question. When I include the
Xerces related code in my CGI, i can not create a cookie on the
client browser.
help me out
grk
On Sun, 07 Apr 2002 ravikanth gangarapu wrote :
>Hi,
> I've got a weird problem using Xerces perl on a web page. I
>have a cgi file to parse an xml document. It uses XML::DOM and
>working very good. Now, I want to do that using XML::Xerces. So,
>I modified the file appropriately( as far as i know). But, This
>Xerces version of CGI file and doesnot show me the http session
>objects. It sets the cookie in browser(for first time). but, when
>i view the page 2nd time it doesnot show(contain) any of the
>session objects that i put in the first time i used that page. i
>am using CGI.pm and Apache::Session::DB_File. But, the XML::DOM
>used CGI is working just fine. This may not be Xerces problem.
>But, I thought you may know.
>
>Please help this stupid.
>
>i put the XML::DOM's CGI file as attachment..
>
>
>The Xerces used CGI is this.
>
>#!/usr/bin/perl -w
>use strict;
>
>use lib qw(.);
>
>use CGI;
>use Apache::Session;
>use Apache::Session::DB_File;
>use XML::Xerces;
>use XML::Xerces::DOMParse;
>
>
>my $q = new CGI;
>
>
>
>#################### SETUP SESSION ########################
>my $cookie='';
>my %cookies = CGI::Cookie->fetch;
>my $session_id;
>my %session=();
>
>my $session_args = {
> FileName => '/tmp/sessions.db',
> LockDirectory => '/tmp',
>};
>
>if (exists $cookies{'SESSION_ID'}) {
> $session_id = $cookies{'SESSION_ID'}->value;
> eval {
> tie %session, 'Apache::Session::DB_File', $session_id ,
> $session_args or die "Cannot tie\n" ;
> };
> if ($@) {
> print STDERR "error: $@";
> undef $session_id;
> };
>}
>unless ($session_id) {
> tie %session,'Apache::Session::DB_File',undef,$session_args
> or die "tie failed: $!\n";
> $session_id = $session{_session_id};
> $cookie = new CGI::Cookie(
> -name=>'SESSION_ID',
> -value=>$session_id,
> -expires=>'+1M',
>
> );
>}
>######################## SESSION DONE ########################
>
>my $doc;
>my $jscode='';
>my $sesobj;
>
>
>#sample.xml is the file i am using as default file . sample.xml
>is just a tiny xml document.
>
>$session{'filename'} ||= "./sample.xml";
>my $filename=$session{'filename'};
>
>$doc = $session{'document_object'};
>
>if(defined $doc)
>{ $sesobj =$session{'document_object'}; }
>
>
>unless (defined $doc ) {
> $sesobj="empty";
> my $parser = XML::Xerces::DOMParser->new();
> $parser->setValidationScheme
>($XML::Xerces::DOMParser::Val_Never);
>$parser->setDoNamespaces (0);
>$parser->setCreateEntityReferenceNodes(0);
>$parser->setDoSchema (0);
>my $ERROR_HANDLER = XML::Xerces::PerlErrorHandler->new();
>$parser->setErrorHandler($ERROR_HANDLER);
>
> if (-e "$filename") {
>
>$parser->parse(XML::Xerces::LocalFileInputSource->new($filename));
> $doc =$parser->getDocument();
> $session{'document_object'} = $doc;
> }
>};
>
>my $rootnode = $doc->getDocumentElement();
>my $rootnodename = $rootnode->getNodeName();
>
>my $currentnode = $rootnode;
>my $str = '';
>my $nav .= qq {<a
>href="xmledit1.cgi">$bfont$rootnodename$sfont</a>\ > \ };
>
>print $q->header(-cookie=>[ $cookie ] ,-Pragma=>'no-cache');
>
>print qq {<html>
> <head>
> <script language="JavaScript">
> window.name='main';
> $jscode
> </script>
> </head>
> <body bgcolor="#ffffff">
>
> <table bgcolor="#D8D8D8" border="0" cellspacing="0"
>cellpadding="4" width="90%"
> align="center">
> <tr><td align="center" colspan="4" bgcolor="#0057AE">
> <font color="#FFFFFF" face="Arial" size="4">
>editing</font></th></td>
> session object at the beginning of CGI is $sesobj
>};
>
>print qq{navigation is $nav };
>
>
>
>print qq{
> <tr> <td colspan="4" bgcolor="#0057AE"> </td></tr>
> </table>
> </form>
> </body>
> </html>
>};
>
>
>please help me out.
>Thanks
>grk
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail:
>[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]