PDA

View Full Version : Can I use Cocoon as a datasource?


onawave
10-31-2007, 06:20 AM
Hello,

I am going back and forth working on UI widgets but then back to look at my JSP java backend as I am unsure what ExtJS can handle.

I have other systems that use Apache Cocoon to serve the data or content based on a 'sitemap.xmap. file.

The 'XML' returned looks like this:

<dir:directory name="Music" lastModified="1193753209125" date="30/10/07 14:06" size="0" sort="name" reverse="false" requested="true">
<dir:directory name="Amy Winehouse" lastModified="1193676529130" date="29/10/07 16:48" size="0">
<dir:directory name="Back to Black" lastModified="1193676529130" date="29/10/07 16:48" size="0">
<dir:file name="01 Rehab.mp3" lastModified="1170067706000" date="29/01/07 10:48" size="8604778"/>
<dir:file name="02 You Know I'm No Good.mp3" lastModified="1170067702000" date="29/01/07 10:48" size="10294378"/>
<dir:file name="03 Me & Mr Jones.mp3" lastModified="1170067650000" date="29/01/07 10:47" size="6134639"/>
<dir:file name="04 Just Friends.mp3" lastModified="1170067712000" date="29/01/07 10:48" size="7739602"/>
<dir:file name="05 Back to Black.mp3" lastModified="1170067698000" date="29/01/07 10:48" size="9659080"/>
<dir:file name="06 Love Is a Losing Game.mp3" lastModified="1170067704000" date="29/01/07 10:48" size="6223455"/>
<dir:file name="07 Tears Dry on Their Own.mp3" lastModified="1170067710000" date="29/01/07 10:48" size="7464794"/>
<dir:file name="08 Wake Up Alone.mp3" lastModified="1170067706000" date="29/01/07 10:48" size="8886900"/>
<dir:file name="09 Some Unholy War.mp3" lastModified="1170067574000" date="29/01/07 10:46" size="5714590"/>
<dir:file name="10 He Can Only Hold Her.mp3" lastModified="1170067708000" date="29/01/07 10:48" size="6663357"/>
<dir:file name="11 Addicted.mp3" lastModified="1170067684000" date="29/01/07 10:48" size="6611112"/>
</dir:directory>
</dir:directory>
</dir:directory>

One example of XML being returned refers to Directory structures. Normally an .xslt stylesheet would be used to format the XML but I would like to read it using a TreeLoader.

But I read somewhere ExtJS doesn't like the ":" in XML. Is this true? Makes it a little hard for me to use Apache Cocoon if this is the case so just wanted to be sure. As far as I know the ":" is a standard part of the XML generator within Cocoon, so changing it would be difficult.

Thanks for helping,
Mark

JeffHowden
10-31-2007, 07:27 AM
Yeah, XML namespaces aren't supported. Your options are to process the XML that cocoon returns and:


Do a quick and dirty search and replace on dir: changing it to just dir.
Transform the XML using XSLT to non-namespaced XML.
Transform the XML using XSLT to JSON


Personally, if it was me, I'd go with the last option as the payload size is smaller and the parsing time is many times less (evaling some JSON takes no time compared to parsing an XML doc).

onawave
10-31-2007, 11:53 AM
Thanks for the info.

I will have a search for info on converting xml to json using xslt.

Not used xlst before so any pointers for where to look would be great.

Thanks for your help.

Mark