You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by go...@osmosis.gr on 2004/05/18 20:52:34 UTC

where to store a large XML

hi people

i have a .xsp that read from a database and create a .xml file that 
describe a tree, then the data from this xml are transformed to a 
javascript tree

the problem is that i need the xml data from the database in each request 
to create the tree (navigation tree) but some times those data produce a 
.xml with 7000 - 10000 nodes. so i have to wait some minutes to ge a 
responce.

my question is:

where can i store temporary the produced XML (i can not use file system) 
so not to have to call .xsp in each request? 
is it possible to store the tree in SESSION ?


thanx 

--stavros



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: where to store a large XML

Posted by Thomas Nichols <nx...@yahoo.co.uk>.
Have you considered storing the XML in an XML db like eXist?
    - Thomas.

gounis@osmosis.gr wrote:

>thnx rof your hints but 
>
>the problem is that i dont want to chache the xsp but the xml content that 
>xsp generate. The XSP run a esql query and produce a 7000-10000 nodes xml 
>i want to avoid runing the xsp (java) code again and again
>
>-- stavros 
>
>
>On Thu, 20 May 2004, Joerg Heinicke wrote:
>
>  
>
>>On 19.05.2004 13:37, iyy wrote:
>>
>>    
>>
>>>use caching.
>>>
>>>http://server:8080/cocoon/docs/userdocs/concepts/caching.html
>>>      
>>>
>>Caching is the way to go. You can either make your XSP cacheable (e.g. 
>>by using ExpiresValidity) or configure the pipeline to be cacheable 
>>("expires 1 hour" or similar).
>>
>>Dotring such a huge XML tree in session will probably lead fast to an 
>>OutOfMemoryError.
>>
>>Joerg
>>
>>    
>>
>>>>>i have a .xsp that read from a database and create a .xml file that
>>>>>describe a tree, then the data from this xml are transformed to a
>>>>>javascript tree
>>>>>
>>>>>the problem is that i need the xml data from the database in each request
>>>>>to create the tree (navigation tree) but some times those data produce a
>>>>>.xml with 7000 - 10000 nodes. so i have to wait some minutes to ge a
>>>>>responce.
>>>>>
>>>>>my question is:
>>>>>
>>>>>where can i store temporary the produced XML (i can not use file system)
>>>>>so not to have to call .xsp in each request?
>>>>>is it possible to store the tree in SESSION ?
>>>>>          
>>>>>
>>>>WriteDOMSessionTransformer should be your friend:
>>>>        
>>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>>    
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: where to store a large XML

Posted by Askild Aaberg Olsen <as...@xangeli.com>.
gounis@osmosis.gr wrote:
> > That's what they are trying to tell you; how to cache the result of 
> > the XSP, not the XSP itself (this is done automaticly by the Cocoon 
> > caching pipeline)
> > 
> > If you add the following code to your XSP, the result (not the XSP) 
> > will be cached for 120 seconds:
> > 
> >     public SourceValidity getValidity() {
> >        int validity = 120;
> >        return new ExpiresValidity(validity * 1000);
> >     }
> > 
> > Add this in the /xsp:page/xsp:logic-element.
> > 
> > Askild
> > -
> 
> thnx askild
> 
> this is exactly what i need but with one modification
> is it possible to turn cache ON/OFF manualy?

Great. Glad I could help! :)

There at least 2 possibilities, depending on what you want.

If you want to change this manually at the server, for debugging etc. you
can switch to a noncaching-pipeline (see <map:pipes>-section in root
sitemap)

If you need a more dynamic solution, and need this to be configurable from
the client, you can pass the timeout to the pipeline as a request parameter:

    public SourceValidity getValidity() {
       // keep in cache for our validity time
       int validity = 120;
       try {
		validity =
Integer.valueOf(parameters.getParameter("validity")).intValue();
	} catch(Exception e) {
            // keep default value
       }       
       return new ExpiresValidity(validity * 1000);
    }

I guess that you must change the getKey()-method also:

    public Serializable getKey()
    {
           try {
           	return "" + parameters.getParameter("pageKey");
           	} catch(Exception e) {
           	return "";
           	}
    }

Sitemap snippet:

<map:generate type="serverpages" src="yourpage.xsp">
	<map:parameter name="validity" value="{request:validity}"/>
	<map:parameter name="pageKey" value="{request:validity}"/>
</map:generate>

This closely resembles an approach that I have been using with great success
:)

Askild
-


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: where to store a large XML

Posted by go...@osmosis.gr.
On Thu, 20 May 2004, Askild Aaberg Olsen wrote:

> gounis@osmosis.gr wrote:
> > 
> > thnx rof your hints but 
> > 
> > the problem is that i dont want to chache the xsp but the xml 
> > content that 
> > xsp generate. The XSP run a esql query and produce a 
> > 7000-10000 nodes xml 
> > i want to avoid runing the xsp (java) code again and again
> 
> That's what they are trying to tell you; how to cache the result of the XSP,
> not the XSP itself (this is done automaticly by the Cocoon caching pipeline)
> 
> If you add the following code to your XSP, the result (not the XSP) will be
> cached for 120 seconds:
> 
>     public SourceValidity getValidity() {
>        int validity = 120;
>        return new ExpiresValidity(validity * 1000);
>     }
> 
> Add this in the /xsp:page/xsp:logic-element.
> 
> Askild
> -

thnx askild

this is exactly what i need but with one modification
is it possible to turn cache ON/OFF manualy?

--stavros

> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


RE: where to store a large XML

Posted by Askild Aaberg Olsen <as...@xangeli.com>.
gounis@osmosis.gr wrote:
> 
> thnx rof your hints but 
> 
> the problem is that i dont want to chache the xsp but the xml 
> content that 
> xsp generate. The XSP run a esql query and produce a 
> 7000-10000 nodes xml 
> i want to avoid runing the xsp (java) code again and again

That's what they are trying to tell you; how to cache the result of the XSP,
not the XSP itself (this is done automaticly by the Cocoon caching pipeline)

If you add the following code to your XSP, the result (not the XSP) will be
cached for 120 seconds:

    public SourceValidity getValidity() {
       int validity = 120;
       return new ExpiresValidity(validity * 1000);
    }

Add this in the /xsp:page/xsp:logic-element.

Askild
-


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: where to store a large XML

Posted by go...@osmosis.gr.
thnx rof your hints but 

the problem is that i dont want to chache the xsp but the xml content that 
xsp generate. The XSP run a esql query and produce a 7000-10000 nodes xml 
i want to avoid runing the xsp (java) code again and again

-- stavros 


On Thu, 20 May 2004, Joerg Heinicke wrote:

> On 19.05.2004 13:37, iyy wrote:
> 
> > use caching.
> > 
> > http://server:8080/cocoon/docs/userdocs/concepts/caching.html
> 
> Caching is the way to go. You can either make your XSP cacheable (e.g. 
> by using ExpiresValidity) or configure the pipeline to be cacheable 
> ("expires 1 hour" or similar).
> 
> Dotring such a huge XML tree in session will probably lead fast to an 
> OutOfMemoryError.
> 
> Joerg
> 
> >>>i have a .xsp that read from a database and create a .xml file that
> >>>describe a tree, then the data from this xml are transformed to a
> >>>javascript tree
> >>>
> >>>the problem is that i need the xml data from the database in each request
> >>>to create the tree (navigation tree) but some times those data produce a
> >>>.xml with 7000 - 10000 nodes. so i have to wait some minutes to ge a
> >>>responce.
> >>>
> >>>my question is:
> >>>
> >>>where can i store temporary the produced XML (i can not use file system)
> >>>so not to have to call .xsp in each request?
> >>>is it possible to store the tree in SESSION ?
> >>
> >>WriteDOMSessionTransformer should be your friend:
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: where to store a large XML

Posted by Joerg Heinicke <jo...@gmx.de>.
On 19.05.2004 13:37, iyy wrote:

> use caching.
> 
> http://server:8080/cocoon/docs/userdocs/concepts/caching.html

Caching is the way to go. You can either make your XSP cacheable (e.g. 
by using ExpiresValidity) or configure the pipeline to be cacheable 
("expires 1 hour" or similar).

Dotring such a huge XML tree in session will probably lead fast to an 
OutOfMemoryError.

Joerg

>>>i have a .xsp that read from a database and create a .xml file that
>>>describe a tree, then the data from this xml are transformed to a
>>>javascript tree
>>>
>>>the problem is that i need the xml data from the database in each request
>>>to create the tree (navigation tree) but some times those data produce a
>>>.xml with 7000 - 10000 nodes. so i have to wait some minutes to ge a
>>>responce.
>>>
>>>my question is:
>>>
>>>where can i store temporary the produced XML (i can not use file system)
>>>so not to have to call .xsp in each request?
>>>is it possible to store the tree in SESSION ?
>>
>>WriteDOMSessionTransformer should be your friend:

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: where to store a large XML

Posted by iyy <iy...@apparelxml.net>.
use caching.

http://server:8080/cocoon/docs/userdocs/concepts/caching.html

----- Original Message -----
From: "Stephan Coboos" <cr...@gmx.net>
To: <us...@cocoon.apache.org>
Sent: Wednesday, May 19, 2004 2:25 PM
Subject: Re: where to store a large XML


> gounis@osmosis.gr wrote:
>
> >hi people
> >
> >i have a .xsp that read from a database and create a .xml file that
> >describe a tree, then the data from this xml are transformed to a
> >javascript tree
> >
> >the problem is that i need the xml data from the database in each request
> >to create the tree (navigation tree) but some times those data produce a
> >.xml with 7000 - 10000 nodes. so i have to wait some minutes to ge a
> >responce.
> >
> >my question is:
> >
> >where can i store temporary the produced XML (i can not use file system)
> >so not to have to call .xsp in each request?
> >is it possible to store the tree in SESSION ?
> >
> >
> WriteDOMSessionTransformer should be your friend:
>
http://cocoon.apache.org/2.1/userdocs/transformers/writedomsession-transform
er.html
>
> Regards
> Stephan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: where to store a large XML

Posted by Stephan Coboos <cr...@gmx.net>.
gounis@osmosis.gr wrote:

>hi people
>
>i have a .xsp that read from a database and create a .xml file that 
>describe a tree, then the data from this xml are transformed to a 
>javascript tree
>
>the problem is that i need the xml data from the database in each request 
>to create the tree (navigation tree) but some times those data produce a 
>.xml with 7000 - 10000 nodes. so i have to wait some minutes to ge a 
>responce.
>
>my question is:
>
>where can i store temporary the produced XML (i can not use file system) 
>so not to have to call .xsp in each request? 
>is it possible to store the tree in SESSION ?
>  
>
WriteDOMSessionTransformer should be your friend:
http://cocoon.apache.org/2.1/userdocs/transformers/writedomsession-transformer.html

Regards
Stephan


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org