[daisy] How to navigate XmlObjectXMLizable in JX Templates?

Robert Cecil rob.cecil at gmail.com
Tue Jan 2 20:03:08 CST 2007


Funny,

during the quiet after my initial post this is precisely what I came  
up with. I just wasn't sure it was 'best practice' NOT to use  
XmlObjectXMLizable.

Thanks

Rob


On Jan 2, 2007, at 4:13 AM, Bruno Dumon wrote:

> On Wed, 2006-12-27 at 14:59 -0500, Robert Cecil wrote:
>> Hi I am building a couple of custom search functions, taking the
>> approach:
>>
>>
>> 1. A Flowscript that performs a query against the Query manager.
>> 2. Creates a new  XmlObjectXMLizable object, using
>> the searchResultDocument from the query output.
>> 3. Stuff that object into a viewData, and
>> 4. Calling cocoon.sendPage() for a JX template.
>>
>>
>> I would like to be able to parse the  XmlObjectXMLizable object in my
>> template but I can't seem to infer the structure. To test, I added
>> temporarily
>>
>>
>> <jx:out value="${pageXml}" />
>>
>>
>> to my template, and I can see the unformatted results in my page.
>>
>>
>> I would like to be able do something like:
>>
>>
>> <jx:forEach var="row" items="${pageXml.searchResult.rows}" >
>>
>>
>> And iterate over each row.
>>
>
> Simply don't wrap the searchResultDocument in an  
> XmlObjectXMLizable, and
> you'll be able to do such things.
>
> The items expression doesn't need to start with "pageXml", but with  
> the
> key with which the searchResultDocument is put in the viewData. So if
> you do
>
> viewData["searchResultDocument"] = searchResultDocument;
>
> then you'd use
>
> <jx:forEach var="row"  
> items="searchResultDocument.searchResult.rows.rowArray">
>   ${row.documentId}, ${row.valueArray[0]}
> </jx:forEach>
>
> [I didn't test the above]
>
> i.o.w. the expressions used in JXTemplate directly work on the Java
> objects made available through the viewData, and not on the XML
> structure of the template or so.
>
> -- 
> Bruno Dumon                             http://outerthought.org/
> Outerthought - Open Source, Java & XML Competence Support Center
> bruno at outerthought.org                          bruno at apache.org
>
> _______________________________________________
> daisy community mailing list
> Professional Daisy support: http://outerthought.org/site/services/ 
> daisy/daisysupport.html
> mail to: daisy at lists.cocoondev.org
> list information: http://lists.cocoondev.org/mailman/listinfo/daisy



More information about the daisy mailing list