Hi Mike,

Caveat Emptor: what follows apply for the version of XPS that comes with
XML::XPathScript. The behavior of this module is however mostly backward
compatible with the classic AxKit::Language::XPS, so it should also apply there.

Maximus Caveat Emptor: my computer is down at the moment, so I wasn't able to
test the example below to the fullest. So expect braindead mistakes to be
scattered across the code. :-) 


Mike Trotman <[EMAIL PROTECTED]> said:
> For some reason it looks like all the print statements get output after 
> the end of the apply_templates output;
> i.e. - after my documents closing element.

This is expected behavior (I could tell you the technical reasons, but will
refrain of doing so unless you expressly request to be bored to tears). To
output stuff from within a testcode function, the true-and-tried method is to
append to $t->{pre}. E.g.:

$t->{a}{testcode} = sub {
  my ( $n, $t ) = @_;
  $t->{pre} .= "blah blah";
  return DO_SELF_AND_KIDS();
};

> But this doesn't let me process child nodes AFTER they have been output 
> (and before something else searches them).
> I.e. I would need $t->{D}{post} to actually be a subroutine.
> 
> Is there some basic 'gotcha' that I am missing?
> 
> Or is this too garbled - and some more concrete code would help?

I'm not overly sure I got all the subtilities of your problem, but -- in the
remote possibility I actually did -- I think the following would do what you 
want:

$t->{a}{testcode} = sub {
  my( $n, $t ) = @_;
  my @children = $n->findnodes( './*' );

  # e.g., add an attribute to all children
  $_->setAttribute( adhoc => 'hi there!' ) for @children;

  # process the kiddies
  $t->{pre} .= apply_templates( $_  ) for @children;

  # strip the attribute away from the kids 
  # well, kinda, I just don't have the proper function
  # close by hand right now :-P
  $_->setAttribute( adhoc => '' ) for @children;

  # don't do the children; their output already have been
  # generated above
  return DO_SELF_ONLY;
};


> Also - I cannot get expression interpolation to work.
> Wherever I put
> 
> PerlSetVar AxXPSInterpolate 1
> 
> I still get the un-interpolated text in my output.
> 
> Has anyone else had problems with this?

I would have to check if AxXPSInterpolate works well with the classic XPS. But
you might want to give a try to the replacement module bundled with
XML::XPathScript which - AFAIK - works. 

Joy,
`/anick

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

Reply via email to