Hi,

Could anyone shed any light on what is going on here? Sorry if this
is a bit verbose and confused but i am very new to XML.

What i am trying to do is open and parse an XML file from within my
XPathScript stylesheet. I am using XML::Parser and have written SAX 
handlers for Start, End and Char.

The sequence of events is:

Request a page from web server. - index.xml
index.xml gets processed by default.xps - my stylesheet
In default.xps, I am opening and parsing another XML file:

$xp = new XML::Parser();
$xp->setHandlers(Start => \&start, End => \&end, Char => \&cdata);
$ce = "";
$xp->parsefile("/some/dodgy/xml/file.xml");


and populating a hash with some data i pull out of there which matches
certain data in index.xml


sub end() {
  my ($parser, $name) = @_;
  $ce = lc($name);
  if (($ce eq 'desc')) { # end of element
    if ($location) { # if a match was found
      $required{$location} = $description;
    }
  }
}


I then build a table with the values of the hash using a while loop
to print out the key => value pairs and send all this
stuff to the browser.

<HTML>
<more html>

<% while ( ($k,$v) = each %required ) {
     print "<tr><td><a href='$k'>$v</a></td></tr>";
   }
%>

<more html
</HTML>

This works the first time you request the page, but if i refresh,
the hash is empty and my table doesnt get built. If i keep refreshing,
the hash stays empty, but if I make a change to the code and then 
refresh again, the hash is populated again.

Its as though the data from index.xml gets written to the browser by
the XPathScript before the 'other' XML file has been opened.

I am very new to AxKit, XML, SAX and XPathScript and am not sure that what
i am doing is efficient or sane so if anyone could point out where
im going wrong or a better way to do it i would be mucho in their
debto. :-)

Thanks

Martin


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

Reply via email to