Mailing List Archive

Problems customizing selected form elements output
Hello,

Using embperl 2.2.0 I would like to use embperl feature that allows
automatic input values filling and checkbox, option and radio button
checking when correct values are specified in %fdat. The problem is that for
example for selected input type="checkbox" html generated by Embperl is

<input type="checkbox" value="1" checked>

This is a problem because I use EMBPERL_RECIPE EmbperlXSLT and pass
everything through XSLT. But XSLT expects valid XML as input so it fails to
parse the invalid checked attribute.

I would like embperl to generate html code like

<input type="checkbox" value="1" checked="checked" />

I also tried EMBPERL_OUTPUT_MODE 1 but checked input was still generated as
checked instead of checked="checked".

I tried looking/modifying Embperl::Syntax with no success.
Also modifying epcmd.c (is that file even used - could not find any
references in make log when compiling) and finally epcmd2.c.
But I could not achieve what I need. I could of course use EmbperlBlocks
syntax and prevent all HTML processing but I like %fdat "magic" too much.

What would I have to change to modify this behaviour? Or maybe there are
patches in CVS/SVN?

All the best,
Villu
Re: Problems customizing selected form elements output [ In reply to ]
Hi again,

Well I have partially achieved what I want. I took a good look on the
Embperl::Syntax::* code and documentation again and figured out that I can
do what I want by using _ep_sa (XML::Embperl::DOM::Element::iSetAttribut in
DOM.xs) function instead of Embperl::Cmd::InputCheck.

In case anyone is interested I give here original and replaced code from
EmbperlHTML.pm (actually I made a new syntax to prevent overwriting core).

original:

$self -> AddTag ('input', ['type', 'name', 'value'], ['src'], ['checked'],
{
perlcode =>
[
'Embperl::Cmd::InputCheck (%$n%, %&*\'name%,
%&*\'value%, %&\'checked%) ; %&=-type:radio|checkbox% ',
#'_ep_sa(%$n%, \'checked\', \'checked\')
if($fdat{%&*\'name%}); %&=-type:radio|checkbox% ',
'$idat{%&*\'name%}=$fdat{%&*\'name%} ; _ep_sa(%$n%,
\'value\', exists ($fdat{%&*\'name%})?$fdat{%&*\'name%}:\'\') ;
%&!-value%',
'$idat{%&*\'name%}=%&*\'value% ; ',
]
}) ;

replaced:

$self -> AddTag ('input', ['type', 'name', 'value', 'checked'], ['src'],
undef,
{
perlcode =>
[
#'Embperl::Cmd::InputCheck (%$n%, %&*\'name%,
%&*\'value%, %&\'checked%) ; %&=-type:radio|checkbox% ',
'_ep_sa(%$n%, \'checked\', \'checked\')
if($fdat{%&*\'name%}); %&=-type:radio|checkbox% ',
'$idat{%&*\'name%}=$fdat{%&*\'name%} ; _ep_sa(%$n%,
\'value\', exists ($fdat{%&*\'name%})?$fdat{%&*\'name%}:\'\') ;
%&!-value%',
'$idat{%&*\'name%}=%&*\'value% ; ',
]
}) ;



But now I have another problem.

When I write my html "xhtml" way (I need to do this because I want to send
embperl output to XSLT processor) then checked or checked="checked" in
replaced EmbperlHTML syntax is inserted at the wrong place

For example

<input type="checkbox" name="c1" value="v1" />

now when I use %fdat magic to check the checkbox embperl generates:

old syntax:
<input type="checkbox" name="c1" value="v1" / checked>
my new modified syntax:
<input type="checkbox" name="c1" value="v1" / checked="checked">

but I need it to generate:

old syntax:
<input type="checkbox" name="c1" value="v1" checked />
my new modified syntax:
<input type="checkbox" name="c1" value="v1" checked="checked" />

So the "checked" is inserted after slash "/", it should be inserted before
it.

What would I have to change (Embperl::Syntax ?) or something else to insert
slash in correct place?

With kind regards,
Villu
RE: Re: Problems customizing selected form elements output [ In reply to ]
Hi,

Please try to use the just uploaded Embperl 2.3.0 and set output mode 1
(xml). This should do the trick without the need of your custom syntax

Gerald


------------------------------------------------------------------------
Besuchen Sie unseren Messestand auf der SYSTEMS vom 23. - 26.10. in
München, Halle B3, Stand 425 www.ecos.de/messen-events/systems-2007.html
------------------------------------------------------------------------
Gerald Richter ECOS electronic communication services GmbH
******************* SECURING YOUR NETWORK ********************

Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz
E-Mail: richter@ecos.de Voice: +49 6133 939-122
WWW: http://www.ecos.de Fax: +49 6133 939-333

Sitz der Gesellschaft: Dienheim; AG Mainz HRB 6889; GF: W.Heck,G.Richter
------------------------------------------------------------------------



> -----Original Message-----
> From: Villu Roogna [mailto:realmerx@gmail.com]
> Sent: Friday, September 07, 2007 9:45 PM
> To: embperl@perl.apache.org
> Subject: Re: Problems customizing selected form elements output
>
> Hi again,
>
> Well I have partially achieved what I want. I took a good
> look on the Embperl::Syntax::* code and documentation again
> and figured out that I can do what I want by using _ep_sa
> (XML::Embperl::DOM::Element::iSetAttribut in DOM.xs) function
> instead of Embperl::Cmd::InputCheck.
>
> In case anyone is interested I give here original and
> replaced code from EmbperlHTML.pm (actually I made a new
> syntax to prevent overwriting core).
>
> original:
>
> $self -> AddTag ('input', ['type', 'name', 'value'], ['src'],
> ['checked'],
> {
> perlcode =>
> [
> 'Embperl::Cmd::InputCheck (%$n%,
> %&*\'name%, %&*\'value%, %&\'checked%) ; %&=-type:radio|checkbox% ',
> #'_ep_sa(%$n%, \'checked\', \'checked\')
> if($fdat{%&*\'name%}); %&=-type:radio|checkbox% ',
> '$idat{%&*\'name%}=$fdat{%&*\'name%} ;
> _ep_sa(%$n%, \'value\', exists
> ($fdat{%&*\'name%})?$fdat{%&*\'name%}:\'\') ; %&!-value%',
> '$idat{%&*\'name%}=%&*\'value% ; ',
> ]
> }) ;
>
> replaced:
>
> $self -> AddTag ('input', ['type', 'name', 'value',
> 'checked'], ['src'], undef,
> {
> perlcode =>
> [
> #'Embperl::Cmd::InputCheck (%$n%,
> %&*\'name%, %&*\'value%, %&\'checked%) ; %&=-type:radio|checkbox% ',
> '_ep_sa(%$n%, \'checked\', \'checked\')
> if($fdat{%&*\'name%}); %&=-type:radio|checkbox% ',
> '$idat{%&*\'name%}=$fdat{%&*\'name%} ;
> _ep_sa(%$n%, \'value\', exists
> ($fdat{%&*\'name%})?$fdat{%&*\'name%}:\'\') ; %&!-value%',
> '$idat{%&*\'name%}=%&*\'value% ; ',
> ]
> }) ;
>
>
>
> But now I have another problem.
>
> When I write my html "xhtml" way (I need to do this because I
> want to send embperl output to XSLT processor) then checked
> or checked="checked" in replaced EmbperlHTML syntax is
> inserted at the wrong place
>
> For example
>
> <input type="checkbox" name="c1" value="v1" />
>
> now when I use %fdat magic to check the checkbox embperl generates:
>
> old syntax:
> <input type="checkbox" name="c1" value="v1" / checked> my new
> modified syntax:
> <input type="checkbox" name="c1" value="v1" / checked="checked">
>
> but I need it to generate:
>
> old syntax:
> <input type="checkbox" name="c1" value="v1" checked /> my new
> modified syntax:
> <input type="checkbox" name="c1" value="v1" checked="checked" />
>
> So the "checked" is inserted after slash "/", it should be
> inserted before it.
>
> What would I have to change (Embperl::Syntax ?) or something
> else to insert slash in correct place?
>
> With kind regards,
> Villu
>
>
>

** Virus checked by BB-5000 Mailfilter **

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Re: Problems customizing selected form elements output [ In reply to ]
Thank you very much. Will be trying it as soon as I get the time.

Could you tell me which files are responsible for the generation of the
(x)html. Is it all in Embperl::Syntax::* or does some of the logic is also
in *.c files.

All the best,
Villu
RE: Re: Re: Problems customizing selected form elements output [ In reply to ]
>
> Thank you very much. Will be trying it as soon as I get the time.
>
> Could you tell me which files are responsible for the
> generation of the (x)html. Is it all in Embperl::Syntax::* or
> does some of the logic is also in *.c files.
>

The difference between html and xhtml is mostly in the C file. In this
case it's in epcmd2.c .

Gerald


** Virus checked by BB-5000 Mailfilter **

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org
Re: Re: Re: Problems customizing selected form elements output [ In reply to ]
Thank you for the information.

VIllu

On 10/10/07, Gerald Richter - ECOS GmbH <richter@ecos.de> wrote:
>
> >
> > Thank you very much. Will be trying it as soon as I get the time.
> >
> > Could you tell me which files are responsible for the
> > generation of the (x)html. Is it all in Embperl::Syntax::* or
> > does some of the logic is also in *.c files.
> >
>
> The difference between html and xhtml is mostly in the C file. In this
> case it's in epcmd2.c .
>
> Gerald
>
>
> ** Virus checked by BB-5000 Mailfilter **
>