On Fri, 2002-08-09 at 06:14, Riley James wrote:
> I noticed mention of "AxAddDynamicProcessor" in the CONTRIB file of the
> distribution, but can't find any information on what it is or does. Could
> someone enlighten me?
> 

I added to to solve a problem I had:  All of our files have the same
extension and same root node...but the contents vary quite a bit. 
Basically we have a meta_info block and then a document block.  The
meta_info block we use to describe what's in the rest of the file and
where to start processing the 'real' document.

AxAddDynamicProcessor allows you to hook into the stylesheet selection
process and base your stylesheet on something else.  In our case, the
stylesheet is based on the selected style (which falls back to 'default'
if none is selected) and the document type (which can be derived from
/icpac/meta_info/root_node/text()).  So for documents which have a
root_node value of "/icpac/college_profile" and the selected style is
'default', then the stylesheet chosen is
"/stylesheets/default-college_profile.xps".  This allows us to add
styles and document types without having to mess with the contents of
already existing files.


Here's our handler for AxAddDynamicProcessor.  It also adds a latex->pdf
converter in the chain if the preferred style is pdf.

---------------------------------------------------------------
package ICPAC::RootNode_Processor;

# return list of anonymous hashes like:
#   {type=>'',media=>'',title=>'',href=>'',alternate=>''}

my $STYLESHEET_ROOT="/stylesheets";
my $DEFAULT_STYLE="default";

sub handler {
    my($provider,$media,$style,$doctype,$dtd,$root)=@_;
    my($document)=$ {$provider->get_strref()};
    $document=~m/<root_node>(.+)<\/root_node>/;
    my($root_node)=$1;
    $root_node=substr($root_node,rindex($root_node,"/")+1);
    my($mstyle)=$style;
    $mstyle=~s/\#//;
    my($filename);
    if(!-e "$ENV{DOCUMENT_HOME}/$STYLESHEET_ROOT/$mstyle-$root_node.xps") {
        print STDERR "**** $ENV{DOCUMENT_HOME}/$STYLESHEET_ROOT/$mstyle-$root_node.xps 
doesn't exist...using default!\n";
        $mstyle=$DEFAULT_STYLE;
    }
    print STDERR "**** Chosen stylesheet:  $mstyle-$root_node.xps\n" 
if(!$ENV{PRODUCTION});

    my @styles;
    push(@styles,{'type'=>'application/x-xpathscript',
                  'href'=>"$STYLESHEET_ROOT/$mstyle-$root_node.xps",
                  'title'=>$style,
                  'alternate'=>0});

    if($mstyle eq "pdf") {
        push(@styles,{'type'=>'text/latex',
                      'href'=>'NULL',
                      'title'=>$style,
                      'alternate'=>0});
    }

    return @styles;

}

1;
--------------------------------------------------------


Brian


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

Reply via email to