<?xml version="1.0" encoding="utf-8"?> <page xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"> <content> <jx:forEach select="#{document/root/path/fileset}"/> #{.} </jx:forEach> </content> </page>
Your example is equivalent to:
JXPathContext cx = JXPathContext.newContext(document);
Node node = (Node)cx.getPointer("/root/path/fileset).getNode();
...The forEach example is equivalent to:
JXPathContext cx = JXPathContext.newContext(document);
Iterator iter = cx.iteratePointers("/root/path/fileset);
while (iter.hasNext()) {
Pointer ptr = (Pointer)iter.next();
Node node = (Node)ptr.getNode();
...
}HTH,
Chris
Leszek Gawron wrote:
Say you have this DOM you pass to a template:
<?xml version="1.0"?> <root> <property file="user.properties" />
<path id="all.cp"> <pathelement location="${build.classes}" /> <fileset dir="${cocoon.lib}"> <include name="*.jar"/> </fileset> <fileset dir="${jetty.lib}"> <include name="*.jar"/> </fileset> <fileset dir="${hsqldb.lib}"> <include name="*.jar"/> </fileset> <fileset dir="${lib}"> <include name="**/*.jar"/> <include name="**/*.zip"/> </fileset> </path> </root>
template follows: <?xml version="1.0" encoding="utf-8"?> <page xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"> <content> #{document/root/path/fileset} </content> </page>
The result is : <?xml version="1.0" encoding="ISO-8859-1"?><page xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"> <content> <fileset dir="${cocoon.lib}"> <include name="*.jar"/> </fileset> </content> </page>
Why doesn't it return all matching nodes and only the first one?
same goes with i.e. #{document/root/*}
A feature or a bug ? lg
