You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Sylvain Wallez <sy...@anyware-tech.com> on 2003/10/21 16:33:03 UTC

JXPath leniency in JXTemplateGenerator

Hi team,

I'd like to add the use of leniency to JXPath expressions in 
JXTemplateGenerator: currently, if a path does not exist, a nice 
exception is thrown. This may be good in some circumstances (avoids 
endless hair pulling sessions to finally discover a small typo), but is 
also required in some situations where the template writer _knows_ that 
a path may not exist.

Here's what I want to do:
- add a global "lenient-xpath" sitemap parameter to the generator. This 
allows to set a global leniency mode (default is false, meaning 
exceptions are raised)
- set leniency always to true on test instructions (<jx:if> and <jx:when>)
- add an optional "lenient" attribute to the <jx:out> and <jx:forEach> 
statements (would default to the sitemap parameter value above).

What do you think?

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Orixo, the opensource XML business alliance  -  http://www.orixo.com



Re: JXPath leniency in JXTemplateGenerator

Posted by Sylvain Wallez <sy...@apache.org>.
Giacomo Pati wrote:

>On Tue, 21 Oct 2003, Sylvain Wallez wrote:
>
>  
>
>>Hi team,
>>
>>I'd like to add the use of leniency to JXPath expressions in
>>JXTemplateGenerator: currently, if a path does not exist, a nice
>>exception is thrown. This may be good in some circumstances (avoids
>>endless hair pulling sessions to finally discover a small typo), but is
>>also required in some situations where the template writer _knows_ that
>>a path may not exist.
>>
>>Here's what I want to do:
>>- add a global "lenient-xpath" sitemap parameter to the generator. This
>>allows to set a global leniency mode (default is false, meaning
>>exceptions are raised)
>>- set leniency always to true on test instructions (<jx:if> and <jx:when>)
>>- add an optional "lenient" attribute to the <jx:out> and <jx:forEach>
>>statements (would default to the sitemap parameter value above).
>>
>>What do you think?
>>    
>>
>
>+1
>

Done (still have to update the docs).

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Orixo, the opensource XML business alliance  -  http://www.orixo.com




Re: JXPath leniency in JXTemplateGenerator

Posted by Giacomo Pati <gi...@apache.org>.
On Tue, 21 Oct 2003, Sylvain Wallez wrote:

> Hi team,
>
> I'd like to add the use of leniency to JXPath expressions in
> JXTemplateGenerator: currently, if a path does not exist, a nice
> exception is thrown. This may be good in some circumstances (avoids
> endless hair pulling sessions to finally discover a small typo), but is
> also required in some situations where the template writer _knows_ that
> a path may not exist.
>
> Here's what I want to do:
> - add a global "lenient-xpath" sitemap parameter to the generator. This
> allows to set a global leniency mode (default is false, meaning
> exceptions are raised)
> - set leniency always to true on test instructions (<jx:if> and <jx:when>)
> - add an optional "lenient" attribute to the <jx:out> and <jx:forEach>
> statements (would default to the sitemap parameter value above).
>
> What do you think?

+1

--
Giacomo Pati
Otego AG, Switzerland - http://www.otego.com
Orixo, the XML business alliance - http://www.orixo.com


RE: JXPath leniency in JXTemplateGenerator

Posted by Reinhard Poetz <re...@apache.org>.
From: Sylvain Wallez

> Hi team,
> 
> I'd like to add the use of leniency to JXPath expressions in 
> JXTemplateGenerator: currently, if a path does not exist, a nice 
> exception is thrown. This may be good in some circumstances (avoids 
> endless hair pulling sessions to finally discover a small 
> typo), but is 
> also required in some situations where the template writer 
> _knows_ that 
> a path may not exist.
> 
> Here's what I want to do:
> - add a global "lenient-xpath" sitemap parameter to the 
> generator. This 
> allows to set a global leniency mode (default is false, meaning 
> exceptions are raised)

+1

> - set leniency always to true on test instructions (<jx:if> 
> and <jx:when>)

+1

> - add an optional "lenient" attribute to the <jx:out> and 
> <jx:forEach>
> statements (would default to the sitemap parameter value above).

+1

This avoids contructs like this, if "bla" can be null:

<jx:if test="#bla">
   <jx:forEach select="#bla/item">
      <myTag/>
   </jx:forEach>
</jx:if>

Reinhard


Re: JXPath leniency in JXTemplateGenerator

Posted by Jeremy Quinn <je...@media.demon.co.uk>.
On Tuesday, October 21, 2003, at 03:33 PM, Sylvain Wallez wrote:

> Hi team,
>
> I'd like to add the use of leniency to JXPath expressions in 
> JXTemplateGenerator: currently, if a path does not exist, a nice 
> exception is thrown. This may be good in some circumstances (avoids 
> endless hair pulling sessions to finally discover a small typo), but 
> is also required in some situations where the template writer _knows_ 
> that a path may not exist.
>
> Here's what I want to do:
> - add a global "lenient-xpath" sitemap parameter to the generator. 
> This allows to set a global leniency mode (default is false, meaning 
> exceptions are raised)
> - set leniency always to true on test instructions (<jx:if> and 
> <jx:when>)
> - add an optional "lenient" attribute to the <jx:out> and <jx:forEach> 
> statements (would default to the sitemap parameter value above).
>
> What do you think?

+1

JXTemplate (which I like and use) always seems very touchy :)
Maybe it could log the times when it had to be lenient.

regards Jeremy