You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lenya.apache.org by Thorsten Scherler <th...@apache.org> on 2006/02/14 15:54:37 UTC

jx:macro in usecase views broken?

Hi all,

I tried today an example found at 
http://cocoon.apache.org/2.1/userdocs/flow/jxtemplate.html
in an usecase view.

I added:

<jx:macro name="d">
  <tr><td></td></tr>
</jx:macro>

and then 
<d/>

to the uscase view but it will not transformed like described in above URL.

Did somebody used jx:macro with success?

TIA for any information

salu2
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: jx:macro in usecase views broken?

Posted by so...@apache.org.
On 2/14/06, Thorsten Scherler <th...@apache.org> wrote:
> El mar, 14-02-2006 a las 13:50 -0500, solprovider@apache.org escribió:
> > When I used JX with Flow, I discovered (what I consider a design flaw)
> > that Cocoon's JX finishes by serializing with a transformation so all
> > angle brackets are converted to "&lt;" and "&gt;".
>
> That sounds really weird, did you report that to cocoon-dev?
>
> > This made it very
> > difficult to return XML and HTML from JX.  If it happens before
> > another transformation, the ruined tags could be ignored.
>
> In the jx-generator or transformer or both?
>
> >  Add a
> > "copy everything" match to your XSL, or add a breakpoint immmediately
> > after the JX, to test if what you expect to be XML is being processed
> > as ugly text.
>
> Actually jx should interpret the <d/> element as call for the macro not
> xsl.


Please ignore me if none of this applies to your issue.

I cannot find my notes on the bug.  I thought I filed a bugzilla for
Cocoon, but I could not find it.  I was certain I mentioned it on the
MLs, but could find nothing.  I thought it was documented on my site,
but it contains how to work around the bug, not the actual code
causing it:

===
"There is a bug in Cocoon so any tags passed to fields are trashed.
You could fix this by removing the line that serializes as XML. It was
bad programming to put it there. If the programmer wanted the &, < and
> changed to &amp;, &lt;, and &gt;, then the programmer could do it
easily. Changing them back after Cocoon destroyed them is much more
work.

Without this bug, you could pass multiple messages that each use i18n with:
form.model.messages = "<i18n:text key=\"error1\">Error 1 has
occurred.</i18n:text><br/><i18n:text key=\"error2\">Error 2 has
occurred.</i18n:text>";

With this bug, the tags will show on your form, and your visitors will
be confused."
===

I was researching why Flow was trashing the HTML created dynamically
in a JS file.  There was the above example, and also our Favorites
field where we needed to pass back a list like:
<a href="/aaa.html">AAA Link</a>
<a href="/bbb.html">BBB Link</a>
but it displayed the HTML source code rather than links.

I traced how the Form was generated through Lenya and Cocoon.  Started
with either the "form" Transformer or the Flow JS classes.  The
function that passed the values back for JX was about 20 files deep. 
I think it was in Cocoon, but it may have been an Avalon/Excalibur
class.  I think the function was less than 10 lines, and included:
"if results are serializable as XML, then send to a function that
serializes angle brackets and ampersands as character codes"
just before the return.  I remember thinking the function would ruin
all attempts to return HTML or XML.  It prevents invalid XML, but it
also severely reduced the usability.

It has been 8 months, and I cannot remember if it was specifically JX,
or was the "forms" transformer.  It has something to do with:
   var form = new Form("form.xml");
   var model = form.getModel();
   model.myfield = "<text>example</text>";
   form.showForm("myform");

I will attempt to repeat my research tonight.  It bothers me that I
cannot find my documentation about it.

solprovider

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: jx:macro in usecase views broken?

Posted by Thorsten Scherler <th...@apache.org>.
El mar, 14-02-2006 a las 13:50 -0500, solprovider@apache.org escribió:
> On 2/14/06, Thorsten Scherler <th...@apache.org> wrote:
> > I tried today an example found at
> > http://cocoon.apache.org/2.1/userdocs/flow/jxtemplate.html
> > in an usecase view.
> >
> > I added:
> > <jx:macro name="d">
> >   <tr><td></td></tr>
> > </jx:macro>
> >
> > and then
> > <d/>
> >
> > to the uscase view but it will not transformed like described in above URL.
> >
> > Did somebody used jx:macro with success?
> 
> We may need more information to understand.  Please add a stripped
> example that reproduces the issue.
> 

Just add the above to *any* usecase in 1.4.

> When I used JX with Flow, I discovered (what I consider a design flaw)
> that Cocoon's JX finishes by serializing with a transformation so all
> angle brackets are converted to "&lt;" and "&gt;".  

That sounds really weird, did you report that to cocoon-dev?

> This made it very
> difficult to return XML and HTML from JX.  If it happens before
> another transformation, the ruined tags could be ignored.  

In the jx-generator or transformer or both?

>  Add a
> "copy everything" match to your XSL, or add a breakpoint immmediately
> after the JX, to test if what you expect to be XML is being processed
> as ugly text.

Actually jx should interpret the <d/> element as call for the macro not
xsl.

Thanks for your thoughts.

salu2

> solprovider
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
> For additional commands, e-mail: dev-help@lenya.apache.org
> 
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: jx:macro in usecase views broken?

Posted by so...@apache.org.
On 2/14/06, Thorsten Scherler <th...@apache.org> wrote:
> I tried today an example found at
> http://cocoon.apache.org/2.1/userdocs/flow/jxtemplate.html
> in an usecase view.
>
> I added:
> <jx:macro name="d">
>   <tr><td></td></tr>
> </jx:macro>
>
> and then
> <d/>
>
> to the uscase view but it will not transformed like described in above URL.
>
> Did somebody used jx:macro with success?

We may need more information to understand.  Please add a stripped
example that reproduces the issue.

When I used JX with Flow, I discovered (what I consider a design flaw)
that Cocoon's JX finishes by serializing with a transformation so all
angle brackets are converted to "&lt;" and "&gt;".  This made it very
difficult to return XML and HTML from JX.  If it happens before
another transformation, the ruined tags could be ignored.   Add a
"copy everything" match to your XSL, or add a breakpoint immmediately
after the JX, to test if what you expect to be XML is being processed
as ugly text.

solprovider

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org