cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 31564] New: - JPath logicsheet jxpath:for-each using relative contexts
Date Wed, 06 Oct 2004 13:48:55 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31564>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31564

JPath logicsheet jxpath:for-each using relative contexts

           Summary: JPath logicsheet jxpath:for-each using relative contexts
           Product: Cocoon 2
           Version: Current CVS 2.1
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: blocks
        AssignedTo: dev@cocoon.apache.org
        ReportedBy: g.brand@interface-business.de


Are you using the jpath logicsheet and have been annoyed that you can't access 
parents or siblings elements in a for-each loop?
like
<jpath:for-each select="myarray">
  <li><jpath:value-of select="/title"> - <jpath:value-of select="."></li>
</jpath:for-each>
won't work because the logicsheet changed the context and /title is not 
available.

There is a simple way to fix that, simply iterating over pointers instead of 
values. This way one can build contexts that are relative to the current one.
So . and non-absolute paths will still point to the iterated element, but 
absolute paths point to the root and siblings etc should work, too.

I wrote that patch a while ago so it is tested and works fine.

---

This patch also adds a new tag to switch the lenient setting of jxpath.
By default it is set to false. If set to true, xpaths that don't point to an 
object or a set of them will return null (Instead of that annoying exception). 
Saves all the checking if you can accept nulls and are sure there are no typos.
<jpath:set-lenient lenient="true|false">
If the tag contains child elements it will scope the setting for the enclosed 
elements, otherwise it is a global setting. You can't nest <jpath:set-lenient> 
tags.

gunnar

ps: the diff file does not have the correct path for the filenames as I had to 
use the webinterface to get the current 2.1 branch jpath.xsl.

Mime
View raw message