You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Dmitry Beransky <db...@ucsd.edu> on 2000/07/31 20:54:06 UTC
XForms & ASP (was: The Template Toolkit )
I'm still pretty vague on where I want to go with this myself :). Just
bits and pieces of ideas. Last night I tried to put something together,
though, and ran into a strange problem which I can't figure out how to
solve. Perhaps, you may have a suggestion, Joshua (the xform markup's
taken directly from w3c's side):
Here's my sample ASP file:
<%@language="PerlScript"%>
<%
use XML::DOM;
use XML::XPath;
my ($xform,$xform_xpath);
%>
<html>
<head>
<xform xmlns="http://www.w3.org/2000/xforms"
action="http://www.my.com/cgi-bin/receiver.pl"
method="postXML"
id="po_xform">
<model>
<group name="purchaseOrder">
<group name="shipTo">
<string name="name"/>
<string name="street"/>
<string name="city"/>
<string name="state"/>
<string name="zip">
<mask>ddddd</mask>
</string>
</group>
</group>
</model>
</xform>
</head>
<body>
<h1>Form</h1>
<form id="po_xform"/>
<form/>
</body>
</html>
<%
sub form
{
}
sub xform
{
my ($attributes, $body) = @_;
my $parser = new XML::DOM::Parser;
$body =~ s/\n//mgs;
$body = "<xform>$body</xform>";
$Response->Write($body );
}
%>
when I run this, I get the following error:
[Mon Jul 31 10:45:53 2000] (eval 76): String found where operator expected at
(eval 76) line 50, at end of line
[Mon Jul 31 10:45:53 2000] (eval 76): (Missing operator before ?)
[Mon Jul 31 10:45:53 2000] [error] [asp] [605] [error] [Mon Jul 31 10:45:53 20
00] (eval 76): Can't find string terminator "'" anywhere before EOF at (eval 7
6) line 50. <--> , /usr/lib/perl5/site_perl/5.005/Apache/ASP.pm line 1740
It doesn't look like I have any runaway strings, so any idea what gives?
Thanks
Dmitry
At 09:01 PM 7/29/00, Joshua Chamas wrote:
>If you could tell me more about this sometime, like where you
>are going with this, and how this might be brought into the
>server to ease developer use that would be great. Its still
>takes a bit to get my head around XML ways of looking at things.
>Dmitry Beransky wrote:
> >
> > That's where the XForm may come quite handy
> > (<http://www.w3.org/MarkUp/Forms/>). The specification is still been
> > worked on, but it has some parts that can already be used on the back
> > end. I can see it (me thinks) fit quite nicely into Apache::ASP XML
> > processor. I thought about coding it up, but never got the time.
> >
Re: XForms & ASP (was: The Template Toolkit )
Posted by Joshua Chamas <jo...@chamas.com>.
Dmitry Beransky wrote:
>
> [Mon Jul 31 10:45:53 2000] (eval 76): String found where operator expected at
> (eval 76) line 50, at end of line
> [Mon Jul 31 10:45:53 2000] (eval 76): (Missing operator before ?)
> [Mon Jul 31 10:45:53 2000] [error] [asp] [605] [error] [Mon Jul 31 10:45:53 20
> 00] (eval 76): Can't find string terminator "'" anywhere before EOF at (eval 7
> 6) line 50. <--> , /usr/lib/perl5/site_perl/5.005/Apache/ASP.pm line 1740
>
> It doesn't look like I have any runaway strings, so any idea what gives?
>
The XMLSubsMatch parser is pretty aggressive, and found a
tag in your <% perl code %> that it tried parsing. If you
had debug 2 set, the output would give you more of a hint
as to what was going on. It doesn't only look for tags
in the HTML segments, though this is what it ought to do.
I would recommend using the Script_OnFlush event handler
to grab all of the data at once and process it with XML, or the
XSLT extension even. You can find the response buffer in
$Response->{BinaryRef} as a scalar reference. This member
is documented at:
http://www.apache-asp.org/objects.html
Only if you are looking to extend all forms with the
the xform might I implement this with XMLSubsMatch.
-- Joshua
_________________________________________________________________
Joshua Chamas Chamas Enterprises Inc.
NodeWorks >> free web link monitoring Huntington Beach, CA USA
http://www.nodeworks.com 1-714-625-4051
Re: XForms & ASP
Posted by Joshua Chamas <jo...@chamas.com>.
Dmitry Beransky wrote:
> ...
> recognizable tokens (as in '<'.'form'). Unfortunately, I cannot use XML or
> XSLT processing, as you recommend, because the content of the tags often is
> HTML. This brings me to another question. Is (would) it possible to do
> recursive recursive XML processing (similar to XSLT) with ASP? Here's an
> example:
>
> <html>
> <head>
> <xform id="formID">
> ...
> </xform>
> </head>
> <body>
> ...
> <asp:form id="formID">
> First name: <asp:input id="firstName"/>
> Last name: <asp:input id="lastName"/>
> </asp:form>
> </body>
> </html>
>
> What I need to do is to process the asp:form element, transform the tag
> itself into appropriate html and then recursively process its content, so
> that I could get to the asp:input tags.
>
If its HTML you need, you could substitute a call to
HTML::Parser instead with a XMLSub <asp:form> to
look for the input tags. You could also do this
all at once at the Script_OnFlush event to parse
both the xform and form at runtime.
If you wanted just a XMLSubsMatch approach, you will have
to work backwards, because inner tags are evaluated
first as sub routines. If you need the input data when you
evaluate the <asp:form>, then you could try using script
globals to capture data for you, like in each input tag
you could set something in $Inputs{$id} = $data and
then reference %Inputs in your <asp:form> ... that's
pretty backwards, and is a limitation with a pure
XMLSubs approach to a problem like this.
Best of luck, and I am very interested in what you
end up with.
-- Joshua