Mon Nov 3 15:01:38 2003

Summary

The idea here is to discuss how to have a single content document, that can change views according to specified criteria.

Maybe your problem is solved, maybe not.

There is an "AxAddDynamicProcessor" directive that can be used in the httpd.conf, I don't think it really solves the problem we are looking at here though. Having a dynamic processor applied to all XML sources is useful in some circumstances, but what if you want to generate a dynamic pipeline differently for different XML sources? Would you code that into the My::Dynamic_processor package?

It makes sense that individual XSP pages might want to do things w/ their pipeline depending on CGI parameters (or countless other criteria). The ability to handle dynamic pipeline generation inline with the other source directives would be useful, and easier to implement than configuring the httpd.conf and creating a whole extra perl module to maintain.

Thoughts

This would be extremely useful. I am working on a project where I could use this functionality right now. I have:

<?xml-stylesheet href="NULL"        type="application/x-xsp"?>
<?xml-stylesheet href="scenario_manager_content.xsl" type="text/xsl"?>
<?xml-stylesheet href="scenario_manager_content_layout.xsl" type="text/xsl"?>
<?xml-stylesheet href="as_html.xsl" type="text/xsl"?>

And what would be nice is if I could send processor directives conditionally, maybe like:

<?xml-stylesheet href="NULL" type="application/x-xsp"?>
<?if test="param('mode')='view'"?> 
    <?xml-stylesheet href="scenario_manager_content.xsl" type="text/xsl"?>
<?fi?>
<?if test="param('mode')='edit'"?>
    <?xml-stylesheet href="scenario_manager_edit.xsl" type="text/xsl"?>
<?fi?>
<?xml-stylesheet href="scenario_manager_content_layout.xsl" type="text/xsl"?>
<?xml-stylesheet href="as_html.xsl" type="text/xsl"?>

Basically, code like this would allow one to specify the pipeline at runtime, based on CGI parameters. Admittedly, I have no idea how to implement this. I also throw into the mix the idea of accessing the query string CGI.pm style.

Could AxKit directives be handled by a perl module? Or does the AxKit source need to be hacked in order to handle this stuff. Hmm.

Looked at it a little bit...

I think it would be easier to work in simple conditions like this:

<?xml-stylesheet href="blahblahblah" type="text/xsl" if="param('test') eq 'someval'"?>

And the 'if' attribute would be parsed out to a simple "eval", and if it came back true, then process the directive, if not, then don't process the directive.

In Apache::AxKit::Provider.pm there is some relevant code that I think will be modified. Still in progress.

Dirty, but effective.

On my box here, I edited the Apache::AxKit::Provider.pm module, and I believe I have a rough cut of what will work. I am using XSP by the way, so my page starts with (as written above):

<?xml-stylesheet href="NULL" type="application/x-xsp"?>
<?xml-stylesheet href="scenario_manager_content_view.xsl" type="text/xsl" if="param('mode') eq 'view' || ! param('mode')"?>
<?xml-stylesheet href="scenario_manager_content_edit.xsl" type="text/xsl" if="param('mode') eq 'edit'"?>
<?xml-stylesheet href="scenario_manager_content_layout.xsl" type="text/xsl"?>
<?xml-stylesheet href="as_html.xsl" type="text/xsl"?>

The good news is, it works. The bad news is, it further deviates from standards. But then again, processor instructions aren't standard. They are processor dependant. But I understand that the xml-stylesheet tag is pretty well accepted... oh well. I am going to use it on my system. I will submit the idea to the authors for inclusion, but doubt it will be in future release. Probably not in current form anyways. But if anyone would like the code for use on their own project, feel free to contact me->.

Or Let your perl code choose the stylesheet

There is a ContentProvider that allows you to specify the preferred stylesheet, each time your page is called, based on whatever conditions you choose. It is Apache::AxKit::Provider::CGI. You can find it on CPAN.

It would be nicer if it allowed you to specify a whole pipeline, instead of a single stylesheet. It could probably be made to do so with just a little re-implementation of the get_styles method.

Thanks for the info, I would go for this myself, but for my project we are using XSP's as the source documents, and thusly normal CGI stuff doesn't quite fit the bill. I'm not sure that it couldn't though. ;) Maybe this could be fitted into XSP pages though. Not sure - didn't look at it close enough. I like the solution that I came up with becuase I don't have to write a bunch of extra perl code (just one little boolean-expression), or use any extra modules. I wanted it to be simple and obvious.

See also

AxKit specifically the section ASSOCIATING STYLESHEETS WITH XML FILES

Using a StyleChooser

There are several plugins that allow you to select a defined style


Edit This Page / Show Page History /