Re: AxKit2 : AxAddRootProcessor

2007-06-19 Thread Martijn

However, something funny happens with the plugin that I've written and
copied below: after the first request, which works fine, there is no
transformation taking place anymore, neither if I reload the same xml
file in the browser, nor if I open a new one. It doesn't happen to the
default demo plugin, so am afraid I am just missing something very
obvious...


Well, I was. Some silly perl referencing mistake. Sorry to have
bothered you. Plugin works fine now.

If anyone is interested in this simple AxAddRootProcessor plugin,
please do let me know.

Martijn.

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



Re: AxKit2 : AxAddRootProcessor

2007-06-18 Thread roseyaxkit . 20 . ftumsh
Martijn,

 So, after the advice I got on this list, I decided to give it a go and
 run AxKit2 to deliver XML-turned-HTML files on our site. The very
 basic setup works well so far: using Apache as a main server and,
 using mod_rewrite, letting .xml files (and only those) be delivered by
 the second AxKit server.

Could you write an idiots guide for that please? It sounds useful.

 In the original setup, there were a lot of XSLT-stylesheets and which
 one(s) to use was decided from the root of the XML document, by using
 a lot of AxAddRootProcessor-entries in the configuration file.

I hated lot's of stylesheet choosing in the config. It depends how
many stylesheets on has I suppose.
Anyhow, at any point in time my app knows what state it is in. ie what
the screen is and therefore the stylesheet. (ajax aside for this
argument). Most of my methods are called state_name of state
and my stylesheets are named name of state.xsl.
I have a method called get_stylesheets which returns an array ref of
hashrefs. An array because there may be a chain of sheets and a hashref
for the name of the sheet and another one for any params
the sheet requires eg:

my $stylesheets = {
[ style = 'name of sheet',
  params = {}
]
  };

The above is very simple, my actual code is a tad more tedious as it
has to cater for pop up windows etc.

So, in my hook_xmlresponse I have a generalised call to an
xml generation method and one that gets all the stylesheets.

I will post the actual methods if you want.

John


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



Re: AxKit2 : AxAddRootProcessor

2007-06-18 Thread Martijn

On 6/18/07, [EMAIL PROTECTED]   So, after the
advice I got on this list, I decided to give it a go and

 run AxKit2 to deliver XML-turned-HTML files on our site. The very
 basic setup works well so far: using Apache as a main server and,
 using mod_rewrite, letting .xml files (and only those) be delivered by
 the second AxKit server.

Could you write an idiots guide for that please? It sounds useful.


The idiot just added the following code to his Apache config file:

RewriteEngine On
RewriteRule \.(gif|jpg|pdf|css|js)$ - [last]
RewriteRule ^/(.*)$ http://localhost:8000/$1 [proxy]

which sends everything but files whose name end on.gif, .jpg etc. to
the AxKit server which runs on the same machine, on port 8000.

However, if I just wanted to do XSLT-translations for my XML files and
have them delivered as HTML to our site's visitors, I would have
forgotten about the whole Apache thing. I wantr to distinguish between
visitors and let the XSLT stylesheets not show certain parts of a page
if they do not have certain session variables set. And in some cases,
I use mod_perl to deny access altogether.

I haven't even started to think about how to do this. But since
URI-translation in Apache (and thus mod_perl) is done before any
authentication takes place, it doesn't look very likely that in this
setup Apache will block any user access.

Thanks also for your suggestions on how to do something similar to
AxAddRootProcessor. I've been playing all afternoon and I've written a
simple plugin that kind of does the trick. Matt is very right when he
claims that writing plugins for AxKit2 is very easy!

However, something funny happens with the plugin that I've written and
copied below: after the first request, which works fine, there is no
transformation taking place anymore, neither if I reload the same xml
file in the browser, nor if I open a new one. It doesn't happen to the
default demo plugin, so am afraid I am just missing something very
obvious...

Martijn.

# the following subroutine is part of demo/serve_myxslt,
# which is very similar to demo/serve_xslt
# (installed with AxKit)

sub hook_xmlresponse {
   my ($self, $input) = @_;

   my $xmlroot = $input-dom-documentElement-nodeName;
   my $rootprocessors = $self-xslt_stylesheets($self-config);
   my @stylefile;
   my $out = $input;
   # $rootprocessors is an array where every even-numbered element is
a stylesheet
   # that should be applied to documents whose root is equal to the
previous element
   # or to any document if that previous element equals a dash

   while (my $root = shift @$rootprocessors and my $stylesheet =
shift @$rootprocessors) {
 if ($root eq '-' || $root eq $xmlroot) {
   push @stylefile, $stylesheet;
 }
   }

   my $out = $input-transform(map XSLT($_), @stylefile);

   return OK, $out;
}

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