You are viewing a plain text version of this content. The canonical link for it is here.
Posted to asp@perl.apache.org by raptor <ra...@unacs.bg> on 2001/08/04 01:10:21 UTC
A proposal..
hi,
just one idea comes to my mind as I'm looking at sub ParseXMLSubs{}...i.e.
Isn't it possible when we use XMLSubsMatch to have one additional option say
XMLSubsDef, what I have in mind :
PerlSetVar XMLSubsDef default
Later on in the ASP.pm (sub ParseXMLSubs{}) /everything on the fly so
excuse if there is errors / :
my($func,$args) = ($1,$2);
my $tagname;
#the new code
if ($self->{xml_subs_def}) {
$func =~ s/\:(.*?)/\:$self->{xml_subs_def}/s;
$tagname = $1;
}
$func =~ s/\:+/\:\:/g;
......
"<% $func({tagname => '$fname', $args}, '');%>"
...
similar several lines below...
What this gives me :
test.html
==========
<html>
....
<my:tag1 .../>
...html code... <my:tag2 />...etc..
my.pm
======
#any usage of tag in "my" namespace goes trought this function
sub default {
};
So what is the benefit :
Because the everything goes trought one function I can easily setup PRE and
POST tag processing, can attach/create a object on first invocation to
handle in a better way the tags, easly can store/cache common info...etc...
Also this way we can bundle easy TagLib modules... Apache::ASP::HomePage,
Apache::ASP::TT :"))
Can we handle in this way Template-loops easily...?
ok i'm giong to sleep...
=====
iVAN
raptor@unacs.bg
=====
PS. I have a couple of XML files from my home page.. which I want to start
making again... but don't want to setup and install AxKit when I already
have and use ASP.pm :")
---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org
Re: A proposal..
Posted by Joshua Chamas <jo...@chamas.com>.
raptor wrote:
> <my:if>
> <%# &my:preif() %>
> <my:else>
> <%# &my:preelse() %>
> </my:else>
> </my:if>
>
> Will my::preif and my:preelse have the access to the HTML code in their
> container ..?
>
At compile time, this type of functionality might have access
to the ASP code in its container as a string only.
> > I would suggest looking also at using XML::Simple for some
> > easy XML parsing. I have used it a couple times, and its
> > really great.
> >
> > Also, the 2.21 Apache::ASP just released
> ]- I see the Cache option .. will it be accessible in other ways-too. This
> look to be a good way of implementing DB-persistency i.e. <<Page-Prev |
> Page-Next>> functionality... :") just thougths..
Yes, I built it generically to be extended for this kind
of use, so one might say ( ONE DAY )
$Server->Cache($CacheKey, $CacheValue [ , $ExpiresTime ])
and then access like:
$Server->Cache($CacheKey);
Also for things like Mason type component caching
where one might say:
$Response->Cache(%CacheAttributes)
$Response->CacheInclude($include, \%CacheAttributes, @args);
> ]- Yes I tried it in the past just before I tried AxKit... in fact I done
> XML-to->HTML conversation for Netscape and olders IE... and for newer-IEs
> used its own XSLT parser... at the time I tried XML::XSLT wasn't very
> mature...didn't looked soon..:") but will check.
Apache::ASP also allows you to use XML::Sablotron with the XSLTParser
setting. I have plans for supporting libXSLT in the future. The big
deal in 2.21 was the file based cache for the XSLT tranformations,
which is a big win for that kind of thing.
> ]- Yes, please...send them to me raptor@unacs.bg ...thanx alot in advance.
I'll send it separately.
--Josh
_________________________________________________________________
Joshua Chamas Chamas Enterprises Inc.
NodeWorks Founder Huntington Beach, CA USA
http://www.nodeworks.com 1-714-625-4051
---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org
Re: A proposal..
Posted by raptor <ra...@unacs.bg>.
> What I mean by post processing is for a tag like this
>
> <my:tag>
> some HTML
> <% # ASP code block %>
> </my:tag>
>
> The &my::tag() sub executes after the contained HTML & ASP
> do, so that its $HTML in $_[1] is static output from the
> wrapped ASP/HTML. You don't get any function executing
> as a preprocessor when the tag begins.
]- now understand :") .. As I said pre-post I meaned something like pre&post
handlers of AxKit... but it is possible with current XMLSubs... but what u
are proposing is very cool .... I think this way is possible to do these
mini-language-tricks ..
(is "<%#' and '%>' the cahrs for the processor to distinguish between
compiletime-ASP and runtime-ASP)
So it will become something like this :
<my:if>
<%# &my:preif() %>
<my:else>
<%# &my:preelse() %>
</my:else>
</my:if>
Will my::preif and my:preelse have the access to the HTML code in their
container ..?
> > > sub XMLTab_OnEnd {} ...
> > ]- Aha U mean XMLSubs happens at runtime not at compile time !?
> >
>
> Yes, a compile time type of XMLSubs would be able to do neat
> tricks by inserting ASP logic into the script.
]- yep.
> I would suggest looking also at using XML::Simple for some
> easy XML parsing. I have used it a couple times, and its
> really great.
>
> Also, the 2.21 Apache::ASP just released
]- I see the Cache option .. will it be accessible in other ways-too. This
look to be a good way of implementing DB-persistency i.e. <<Page-Prev |
Page-Next>> functionality... :") just thougths..
>has a really mature
> XSLT implementation if you want to go that route.
]- Yes I tried it in the past just before I tried AxKit... in fact I done
XML-to->HTML conversation for Netscape and olders IE... and for newer-IEs
used its own XSLT parser... at the time I tried XML::XSLT wasn't very
mature...didn't looked soon..:") but will check.
> Cool, my OSS conference presentation showed ASP use for things just
> like this with the XMLSubs, email me if you want the slides in PDF,
> which I'll likely post online at some point.
]- Yes, please...send them to me raptor@unacs.bg ...thanx alot in advance.
=====
iVAN
raptor@unacs.bg
=====
---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org
Re: A proposal..
Posted by Joshua Chamas <jo...@chamas.com>.
raptor wrote:
> >
> > But, if you really want pre processing & post
> > processing, we need something new, since the current
> > XMLSubs model just handles post processing.
> ]- isn't the XMLSubs replace the tag with function-call before executing the
> ASP code... ?!!
What I mean by post processing is for a tag like this
<my:tag>
some HTML
<% # ASP code block %>
</my:tag>
The &my::tag() sub executes after the contained HTML & ASP
do, so that its $HTML in $_[1] is static output from the
wrapped ASP/HTML. You don't get any function executing
as a preprocessor when the tag begins.
> <my:func/> become <% func() %> ... and then when the time comes it is
> executed..
This is what happens, yes.
> >
> > sub XMLTab_OnEnd {} ...
> ]- Aha U mean XMLSubs happens at runtime not at compile time !?
>
Yes, a compile time type of XMLSubs would be able to do neat
tricks by inserting ASP logic into the script.
> > Rather, then go and build something that noone will use
> > though, let us try to focus this conversation on what
> > you are trying to do exactly...
> ]- Not very-clear idea yet :")... but I want first to try to remake my home
> page with XMLSubs instead of AxKit... 'cause it is not worth it at the
> moment to do full-blown AxKit.-installation... And that's why XMLSubs is the
> right tool to use..
>
I would suggest looking also at using XML::Simple for some
easy XML parsing. I have used it a couple times, and its
really great.
Also, the 2.21 Apache::ASP just released has a really mature
XSLT implementation if you want to go that route.
> ]- let me experiment a litle bit... and when I have a better idea i will
> post again... but I generally think the for such "light-wave" tasks it the
> perfect solution....
> One other thing for which I would like to use it is to separate the design
> from logic (the-template-way)... and this seems like a good way to do it...
> /but if it is handled at compile-time, how it will be possible to pass info
> from ASP script to this virtual-XML-template-system if it executed before
> it.. may-be callbacks?! /
A compile time deal would just be able to add ASP code to the script
instead of dealing with things at runtime. I don't know if it would
be useful for what you are doing, I was just going off on what ifs.
> i.e.
> ASP-object-model + logic-design separation + XML, XSLT transformation.
>
Cool, my OSS conference presentation showed ASP use for things just
like this with the XMLSubs, email me if you want the slides in PDF,
which I'll likely post online at some point.
Later,
Josh
_________________________________________________________________
Joshua Chamas Chamas Enterprises Inc.
NodeWorks Founder Huntington Beach, CA USA
http://www.nodeworks.com 1-714-625-4051
---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org
Re: A proposal..
Posted by raptor <ra...@unacs.bg>.
> Off the top of my head, why have your tags translate to
> my::default, wouldn't this be better to have:
>
> PerlSetVar XMLSubsDefault my::default
>
> then
>
> sub my::default {
> my($tag_name, $args, $html) = @_;
> ...
> }
>
> But, if you really want pre processing & post
> processing, we need something new, since the current
> XMLSubs model just handles post processing.
]- isn't the XMLSubs replace the tag with function-call before executing the
ASP code... ?!!
i.e.
<my:func/> become <% func() %> ... and then when the time comes it is
executed..
> Also for handling things like complex minilanguages,
> we really need a token parser that can create ASP on the
> fly to be parsed during the compilation phase
> that one could say something like:
>
> PerlSetVar XMLTagParse my:\w+
>
> then one could do ASP logic level tranformations
> on the fly like:
>
> <my:if eval="1+1">
> ...
> </my:if>
> <my:else>
> ...
> </my:else>
>
> # global.asa
> sub XMLTag_OnStart {
> my($token, $args) = @_;
> my $script = $Server->{ScriptData};
> if($token eq 'my:if') {
> $$script .= "<% if(".$args->{'eval'}." { %>";
> } elsif($token eq 'my:else') {
> $$script .= "<% } else { %>";
> }
> }
>
> sub XMLTab_OnEnd {} ...
]- Aha U mean XMLSubs happens at runtime not at compile time !?
> I think it would be with this kind of system that
> one could completely model most any other mini language
> like XSP or CFML.
>
> Rather, then go and build something that noone will use
> though, let us try to focus this conversation on what
> you are trying to do exactly...
]- Not very-clear idea yet :")... but I want first to try to remake my home
page with XMLSubs instead of AxKit... 'cause it is not worth it at the
moment to do full-blown AxKit.-installation... And that's why XMLSubs is the
right tool to use..
> BTW, I do like where you are going with this, but would
> like a complete solution for whereever this leads.
]- let me experiment a litle bit... and when I have a better idea i will
post again... but I generally think the for such "light-wave" tasks it the
perfect solution....
One other thing for which I would like to use it is to separate the design
from logic (the-template-way)... and this seems like a good way to do it...
/but if it is handled at compile-time, how it will be possible to pass info
from ASP script to this virtual-XML-template-system if it executed before
it.. may-be callbacks?! /
i.e.
ASP-object-model + logic-design separation + XML, XSLT transformation.
Thanx
=====
iVAN
raptor@unacs.bg
=====
---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org
Re: A proposal..
Posted by Joshua Chamas <jo...@chamas.com>.
raptor wrote:
>
> hi,
>
> just one idea comes to my mind as I'm looking at sub ParseXMLSubs{}...i.e.
> Isn't it possible when we use XMLSubsMatch to have one additional option say
> XMLSubsDef, what I have in mind :
>
> PerlSetVar XMLSubsDef default
>
> Later on in the ASP.pm (sub ParseXMLSubs{}) /everything on the fly so
> excuse if there is errors / :
>
> my($func,$args) = ($1,$2);
> my $tagname;
> #the new code
> if ($self->{xml_subs_def}) {
> $func =~ s/\:(.*?)/\:$self->{xml_subs_def}/s;
> $tagname = $1;
> }
Off the top of my head, why have your tags translate to
my::default, wouldn't this be better to have:
PerlSetVar XMLSubsDefault my::default
then
sub my::default {
my($tag_name, $args, $html) = @_;
...
}
But, if you really want pre processing & post
processing, we need something new, since the current
XMLSubs model just handles post processing.
Also for handling things like complex minilanguages,
we really need a token parser that can create ASP on the
fly to be parsed during the compilation phase
that one could say something like:
PerlSetVar XMLTagParse my:\w+
then one could do ASP logic level tranformations
on the fly like:
<my:if eval="1+1">
...
</my:if>
<my:else>
...
</my:else>
# global.asa
sub XMLTag_OnStart {
my($token, $args) = @_;
my $script = $Server->{ScriptData};
if($token eq 'my:if') {
$$script .= "<% if(".$args->{'eval'}." { %>";
} elsif($token eq 'my:else') {
$$script .= "<% } else { %>";
}
}
sub XMLTab_OnEnd {} ...
I think it would be with this kind of system that
one could completely model most any other mini language
like XSP or CFML.
Rather, then go and build something that noone will use
though, let us try to focus this conversation on what
you are trying to do exactly...
Something that you might try to emulate the XMLSubsDef
that you propose could be something like:
sub my::tag {
&my::default('tag', @_);
}
You could even defined these tags in bulk like this;
for my $tag ( qw(tag tag1 tag2 ) ) {
eval " sub my::$tag { &my::default('$tag', \@_) } ";
}
BTW, I do like where you are going with this, but would
like a complete solution for whereever this leads.
-- Josh
_________________________________________________________________
Joshua Chamas Chamas Enterprises Inc.
NodeWorks Founder Huntington Beach, CA USA
http://www.nodeworks.com 1-714-625-4051
---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org