Thanks Yanick.
[EMAIL PROTECTED] wrote:
This is what I was afraid of and would have expected - but was obviously misled by the example on page 108 in the AxKit book.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(); };
I think something like that might cover what I need to do.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; };
I'm actually pushing and popping an external context stack as I pass through elements.
So - as long as I nest the relevant apply_templates within the matching $t->{...}s within a push and a pop it should work.
I have downloaded this today. I haven't re-tried the interpolation yet - but have used YPathScript successfully in place of XPathScript.
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
-- Datalucid Limited 8 Eileen Road South Norwood London SE25 5EJ / tel :0208-239-6810 mob: 0794-725-9760 email: [EMAIL PROTECTED] / UK Co. Reg: 4383635 VAT Reg.: 798 7531 60
-- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.0.308 / Virus Database: 266.9.2 - Release Date: 05/04/2005
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
