I wrote to the cocoon dev to change this procedure but they think it's clear enough. The this xsp for example.
Thomas
Andreas Doms schrieb:
I need to define a recursive methode which produces nested xml tags.
<xsp:logic>
private void produced(...){
<a> produced(...);
</a>
}
</xsp:logic>
this gives the error "xspAttr cannot be resolved" because the xspAttr is not known the gerated methode.
Any concept to solve this problem elegant?
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE xsp:page [ <!ENTITY % ISOlat1 PUBLIC "ISO 8879-1986//ENTITIES Added Latin 1//EN//XML" "ISOlat1.pen"> %ISOlat1; <!ENTITY % ISOnum PUBLIC "ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN//XML" "ISOnum.pen"> %ISOnum; ]> <!-- Generate the group hierachy --> <!-- --> <!-- @author <a href="[EMAIL PROTECTED]">Thomas Krause</a> --> <!-- @version $Revision: 1.2 $ $Date: 2004/05/14 09:05:27 $ <!-- --> <xsp:page language="java" xmlns:xsp="http://apache.org/xsp" xmlns:xsp-request="http://apache.org/xsp/request/2.0" xmlns:log="http://apache.org/xsp/log/2.0" xmlns:capture="http://apache.org/cocoon/capture/1.0" xmlns:session="http://apache.org/xsp/session/2.0" xmlns:assa-project="http://heimhuber.net/cocoon/assa-project/1.0" > <xsp:structure> <xsp:include>de.heimhuber.emiproject.ejb.*</xsp:include> <xsp:include>java.util.*</xsp:include> </xsp:structure> <!-- go recursive thrue the hierarchy of groups --> <!-- the param xspAttr is required for SAX --> <!-- I think you can also use "AttributesImpl xspAttr = new AttributesImpl();" to create a new xspAttr --> <xsp:logic> private void processGroupHierarchyNode( org.xml.sax.helpers.AttributesImpl xspAttr, GroupHierarchyNode node) throws Exception { Iterator iterator; GroupData group = node.getGroup(); <node> <!-- copy this group part from group.xsp --> <group> <id><xsp:expr>group.getId()</xsp:expr></id> <name><xsp:expr>group.getName()</xsp:expr></name> <xsp:logic> if ( group.getParent() != null ) { <parent> <xsp:attribute name="id"><xsp:expr>group.getParent().getId()</xsp:expr></xsp:attribute> <xsp:expr>group.getParent().getName()</xsp:expr> </parent> } if ( group.getBoss() != null ) { <boss> <xsp:attribute name="id"><xsp:expr>group.getBoss().getId()</xsp:expr></xsp:attribute> <xsp:expr>group.getBoss().getUsername()</xsp:expr> </boss> } if ( group.getApprover() != null ) { <approver> <xsp:attribute name="id"><xsp:expr>group.getApprover().getId()</xsp:expr></xsp:attribute> <xsp:expr>group.getApprover().getUsername()</xsp:expr> </approver> } if ( group.getProjectManager() != null ) { <project-manager> <xsp:attribute name="id"><xsp:expr>group.getProjectManager().getId()</xsp:expr></xsp:attribute> <xsp:expr>group.getProjectManager().getUsername()</xsp:expr> </project-manager> } if ( group.getIsProjectTarget().booleanValue() ) { <is-project-target>1</is-project-target> } else { <is-project-target>0</is-project-target> } if ( group.getProjectControler() != null ) { <project-controler> <xsp:attribute name="id"><xsp:expr>group.getProjectControler().getId()</xsp:expr></xsp:attribute> <xsp:expr>group.getProjectControler().getUsername()</xsp:expr> </project-controler> } if ( group.getProjectTracker() != null ) { <project-tracker> <xsp:attribute name="id"><xsp:expr>group.getProjectTracker().getId()</xsp:expr></xsp:attribute> <xsp:expr>group.getProjectTracker().getUsername()</xsp:expr> </project-tracker> } </xsp:logic> </group> <!-- --> <admins> </admins> <!-- --> <users> </users> <!-- --> <level><xsp:expr>node.getLevel()</xsp:expr></level> <max-childs><xsp:expr>node.getMaxChilds()</xsp:expr></max-childs> <!-- --> <!-- it's for html-table rendering (colspan)--> <xsp:logic> int numberOfChildGroups = node.getChildGroups().size(); if ( numberOfChildGroups == 0 ) { numberOfChildGroups = 1; } </xsp:logic> <number-of-child-groups><xsp:expr>numberOfChildGroups</xsp:expr></number-of-child-groups> <!-- --> <child-groups> <xsp:logic> iterator = node.getChildGroups().iterator(); while ( iterator.hasNext() ) { this.processGroupHierarchyNode( xspAttr, (GroupHierarchyNode)iterator.next() ); } </xsp:logic> </child-groups> </node> } </xsp:logic> <!-- this is the entry point --> <page> <assa-project:error-page>empty.html</assa-project:error-page> <xsp:logic> Iterator hierarchyIterator = GroupUtil.getHome().getGroupHierarchies().iterator(); while ( hierarchyIterator.hasNext() ) { GroupHierarchyNode rootNode = (GroupHierarchyNode)hierarchyIterator.next(); <group-hierarchy> <xsp:attribute name="name"><xsp:expr>rootNode.getGroup().getName()</xsp:expr></xsp:attribute> <xsp:logic> <!-- It's a little bit tricky, but the parameter "xspAttr" is generated while the transformation from xsp to java --> <!-- Please see the resulting java file to validate this --> this.processGroupHierarchyNode( xspAttr, rootNode ); </xsp:logic> </group-hierarchy> } </xsp:logic> </page> </xsp:page>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
