You are viewing a plain text version of this content. The canonical link for it is here.
Posted to asp@perl.apache.org by Philip Mak <pm...@aaanime.net> on 2001/09/08 11:31:31 UTC
Parsing error? with XMLSubs
A greater than sign inside an attribute passed to an XMLSub will cause an
error. This happens even if the greater than sign is enclosed in quotes. I
would think that the parser should be able to distinguish a > inside
quotes from the > that ends the XML tag.
This works:
<s:link href="author.asp">[Edit Author]</s:link>
This does not work:
<s:link href="author.asp" test=">">[Edit Author]</s:link>
BTW, is the following syntax allowed (using <%= %> inside an attribute of
an XMLSub)?
<s:link href="<%=$ENV{SCRIPT_URL}%>">Test</s:link>
(Apache::ASP version 2.21)
---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org
Re: Parsing error? with XMLSubs
Posted by Joshua Chamas <jo...@chamas.com>.
Philip Mak wrote:
>
> On Sat, 8 Sep 2001, Joshua Chamas wrote:
>
> > I'll see if I can get this to work. But the parser is
> > pretty fast now, and it'll be a trick to get this to
> > work and keep it fast.
>
> It's not terribly important, although it would be nice to have. Right now
> I'm using a workaround:
>
> &s::link({href=>'author.asp', query=>{action=>'view', aid=>$aid}}, $author->{name});
>
> instead of
>
> <s:link href="author.asp" query="<%={action=>'view', aid=>$aid}%>">$author->{name}</s:link>
>
> This is a function that I use to generate URLEncoded query strings for me;
> it would become like:
>
> <a href="author.asp?action=view&aid=<%=$Server->URLEncode(aid)%>"><%=$author->{name}%></a>
>
Not that it gives you > in the XMLSubs args, but you
can use $Server->URL for what you are doing to construct
a URL that is escaped like this
<a href="<%=$Server->URL($url, \%params)%>">
You might create an XMLSub like:
<s:link href="here.asp" query_arg1="asdf" query_arg2="asdfa" />
which calls a sub like:
sub s::link {
my($args, $html) = @_;
my $href = delete $args->{'href'};
print "<a href=".$main::Server->URL($href, $args).">$html."</a>";
}
Your query string data is just all the args that aren't href.
--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: Parsing error? with XMLSubs
Posted by Quentin Smith <qu...@comclub.dyndns.org>.
Philip Mak wrote:
>On Sat, 8 Sep 2001, Joshua Chamas wrote:
>
>>I'll see if I can get this to work. But the parser is
>>pretty fast now, and it'll be a trick to get this to
>>work and keep it fast.
>>
>
>It's not terribly important, although it would be nice to have. Right now
>I'm using a workaround:
>
>&s::link({href=>'author.asp', query=>{action=>'view', aid=>$aid}}, $author->{name});
>
>instead of
>
><s:link href="author.asp" query="<%={action=>'view', aid=>$aid}%>">$author->{name}</s:link>
>
>This is a function that I use to generate URLEncoded query strings for me;
>it would become like:
>
><a href="author.asp?action=view&aid=<%=$Server->URLEncode(aid)%>"><%=$author->{name}%></a>
>
>(Feel free to comment if you think my programming habit is atrocious. I
>just thought this up on the fly :)
>
>>Currently what it supported is this:
>>
>> <s:link href="$ENV{SCRIPT_URL}">Test</s:link>
>>
>
>I don't think that would work for what I'm doing above, due to the > in
>"action=>'view'".
>
Don't forget, TMTOWTDI. action => 'view', is the same as 'action', 'view',.
HTH,
--Quentin
---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org
Re: Parsing error? with XMLSubs
Posted by Philip Mak <pm...@aaanime.net>.
On Sat, 8 Sep 2001, Joshua Chamas wrote:
> I'll see if I can get this to work. But the parser is
> pretty fast now, and it'll be a trick to get this to
> work and keep it fast.
It's not terribly important, although it would be nice to have. Right now
I'm using a workaround:
&s::link({href=>'author.asp', query=>{action=>'view', aid=>$aid}}, $author->{name});
instead of
<s:link href="author.asp" query="<%={action=>'view', aid=>$aid}%>">$author->{name}</s:link>
This is a function that I use to generate URLEncoded query strings for me;
it would become like:
<a href="author.asp?action=view&aid=<%=$Server->URLEncode(aid)%>"><%=$author->{name}%></a>
(Feel free to comment if you think my programming habit is atrocious. I
just thought this up on the fly :)
> Currently what it supported is this:
>
> <s:link href="$ENV{SCRIPT_URL}">Test</s:link>
I don't think that would work for what I'm doing above, due to the > in
"action=>'view'".
---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org
Re: Parsing error? with XMLSubs
Posted by Joshua Chamas <jo...@chamas.com>.
Philip Mak wrote:
>
> A greater than sign inside an attribute passed to an XMLSub will cause an
> error. This happens even if the greater than sign is enclosed in quotes. I
> would think that the parser should be able to distinguish a > inside
> quotes from the > that ends the XML tag.
>
> This works:
>
> <s:link href="author.asp">[Edit Author]</s:link>
>
> This does not work:
>
> <s:link href="author.asp" test=">">[Edit Author]</s:link>
>
I'll see if I can get this to work. But the parser is
pretty fast now, and it'll be a trick to get this to
work and keep it fast.
> BTW, is the following syntax allowed (using <%= %> inside an attribute of
> an XMLSub)?
>
> <s:link href="<%=$ENV{SCRIPT_URL}%>">Test</s:link>
>
Currently what it supported is this:
<s:link href="$ENV{SCRIPT_URL}">Test</s:link>
where it becomes:
&s::link({ href=>"$ENV{SCRIPT_URL}" }, "Test" });
Whenever I need to embed a ">" in a perl XMLSub, I just
get that in a variable first, and pass that in. If
this is enough for you, and you don't need the above
to work, let me know.
The args to a XMLSub are treated as perl expressions,
which is why one cannot do:
<s:link href=http://asdfdsaf >
because http://asdfsadf needs to be a quoted string in perl.
--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