I started working on new project about 2 months ago. I am basically replacing a guy that left. He set up a server with AxKit and Apache and I think it's pretty cool stuff. Anyways, I've been getting into it, creating content and what not, and I got to a point in my development where: being able process PI's (processor instructions) CONDITIONALLY, would be an elegant solution to a challenge.
I have a pipeline that looks like this:
XSP -> XSL -> XSL -> XSL (output is HTML)
And the middle to XSL's ( content & layout in my case) should be different depending on a CGI parameter, so:
- XSL(view) -> XSL(view)-
/ \
XSP -> ? > XSL (output is HTML)
\ /
- XSL(edit) -> XSL(edit)-
Using AxAddDynamicProcessor wouldn't really do it, becuase I'm wanting to do tests with CGI params. It would be unelegant to work this kind of functionality into a DynamicProcessorPackage, and then specify that file specifically in the httpd.conf to use that package as the pipeline builder. I dry heave at the thought of extra maintenance that goes into creating whole extra perl module, and modifying the conf so that it refers to my package and XSP document.
I have taken a look at the Apache::AxKit::Provider::CGI module, which Sean McMurray was kind enough to point me towards. It doesn't quite fit the bill. If I read right, his module will prepend the PI to the result XML tree, and the browser is then responsible for transformation. I'm 100% sure on that, more like 90%. Anyways, even if you could apply that module to serverside processing, it's still only applicable for CGI scripts, and I'm doing XSP pages. Similar but not the same.
So I took it upon myself to modify Apache::AxKit::Provider and have satisfied my problem. I think it's simple, and elegant, and ready for review. I find it useful enough that I think it should be included in the Non-Jim-Edited edition of AxKit. But that is the AxKit Author's call.
Here is what my modification allows one to do (snippet at the top of my XML (xsp) source document):
--- snippet ----
<?xml-stylesheet href="NULL" type="application/x-xsp" ?>
<?xml-stylesheet href="scenario_manager_content_edit.xsl" type="text/xsl" if="param('mode') eq 'Modify' || param('mode') eq 'Create New'" ?>
<?xml-stylesheet href="scenario_manager_content_view.xsl" type="text/xsl" if="param('mode') eq 'View' || ! param('mode')" ?>
<?xml-stylesheet href="scenario_manager_content_layout_edit.xsl" type="text/xsl" if="param('mode') eq 'Modify' || param('mode') eq 'Create New'" ?>
<?xml-stylesheet href="scenario_manager_content_layout_view.xsl" type="text/xsl" if="param('mode') eq 'View' || ! param('mode')" ?>
<?xml-stylesheet href="as_html.xsl" type="text/xsl" ?>
--- snippet ----
The addition is the 'if' attribute. Long story short, the code get's eval'd and and the PI is processed based on whether the return value is 'true' or not. The param() function is an illusion. It is the easy way to specify CGI parameters in the statement, but no call to a param() function is ever made. It is just parsed away into using the underlying apache-request object. I thought it was a nice convenience avec convention really.
That's it. So if anyone else would find this useful, let me know and I'll send them the modified code. I personally would like to see this feature make it into regular AxKit, whether it be my code implementation or not.
--Jim
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]