You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Lionel Crine <cr...@4dconcept.fr> on 2003/03/11 14:20:57 UTC

object in a transformer

I have a pipeline in which there is my custom transformer.
In this transformer I have a method which access to an XMLDB and get a 
result object.

I want my transformer to get the object (in a session) and get it to an xsp 
page.

Is it possible to do such a thing ?

Lionel


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


Re: object in a transformer

Posted by Lionel Crine <cr...@4dconcept.fr>.
>Perhaps it would be simpler to manipulate the DOM -- to be precise the
>resulting XML -- with XSL rather than XSP?

For now I manipulate the result object in the transformer :

     for (int i = 0; i <= count; i++) {
                     try {
                         SpecialDocument doc = result.Item(i);
                         String contenT = null;

                         response.append("<doc><name>"+doc.GetName()+"</name></doc>");
....

But I have 30000 documents and the "Item" method is to long. That's why I 
need to get the result out of the transformer.
So I will be able to use "Item" method (in the xsp page) onto how many 
documents I want.


Lionel 


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


Re: object in a transformer

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 11.Mar.2003 -- 05:15 PM, Lionel Crine wrote:
> 
> >Yes. Shouldn't be too big, though, unless you have enough memory.
> >
> >> 2/In the xsp page, haow can I get attribute from the DOM object in the
> >> session ?
> >> Like that : <xsp-session:get-attribute name="the_object_in_the DOM"/>
> >
> >Retrieve the object and use e.g. jxpath or the dom java api on it.
> 
> I'm confused ?
> Here is what I understand :
> 1/ get the DOM from the session with xsp tag ?
> 2/manipulate the DOM with jxpath or DOM api.

Exactly. Check the jxpath logicsheet for example.

> >> 3/If I want the xsp generator to retreive the DOMsessionelement from my
> >> custom transfomer, should I use a resource ?
> >Wait - you want to generate your XSP from a session attribute? Doesn't
> >sound too good to me. Remember that it needs to be compiled everytime
> >it changes.... Apart from that, a source seems to be right.
> 
> 
> for now I have :
>         <map:match pattern="search">
>           <map:generate type="customRequest"/>  -> create sax events
>           <map:transform type="customQuery">
>           </map:transform>
>           <map:transform type="xslt" src="proto/xsl/documents.xsl"/>
>           <map:serialize type="html"/>
>        </map:match>
> 
> and I want :
> 
> 1/  this first pipeline generate a DOM object in a session.
> 
> 
>         <map:match pattern="search">
>           <map:generate type="customRequest"/>  -> create sax events from 
> a form
> first possibility :
>           <map:transform type="customQuery"/> -> get the result of the 
> request and put it in a DOM into a session
> second possibility :
>           <map:transform type="writeDOMsession">
>             <map:parameter name="dom-name" value="result"/>
>             <map:parameter name="dom-root-element" value="docs"/> docs is 
> the root element of the sax event which comes from the first transformer.
>           </map:transform>
>           <xml:serialize/>
>         </map:match>
> 
> 
> 2/ this second pipeline get the DOM, so I could manipulate the result in 
> the xsp page.
>         <map:match pattern="xsppage">
>           <map:generate type="serverpages" src="anyxsp.xsp"/> -> Get, I 
> don't know how the DOM session object
>           <map:transform type="xslt" src="demo/documents.xsl"/>
>           <map:serialize/>
>         </map:match>
> 
> Furthermore, I don't know how to link the two pipeline!

You need to put a link on the first pipeline's result that points to
the second and hope that the user requests it (or force it via refresh
/ javascript / whatever).

Perhaps it would be simpler to manipulate the DOM -- to be precise the
resulting XML -- with XSL rather than XSP?

	Chris.
-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

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


Re: object in a transformer

Posted by Lionel Crine <cr...@4dconcept.fr>.
>Yes. Shouldn't be too big, though, unless you have enough memory.
>
> > 2/In the xsp page, haow can I get attribute from the DOM object in the
> > session ?
> > Like that : <xsp-session:get-attribute name="the_object_in_the DOM"/>
>
>Retrieve the object and use e.g. jxpath or the dom java api on it.

I'm confused ?
Here is what I understand :
1/ get the DOM from the session with xsp tag ?
2/manipulate the DOM with jxpath or DOM api.


> > 3/If I want the xsp generator to retreive the DOMsessionelement from my
> > custom transfomer, should I use a resource ?
>Wait - you want to generate your XSP from a session attribute? Doesn't
>sound too good to me. Remember that it needs to be compiled everytime
>it changes.... Apart from that, a source seems to be right.


for now I have :
         <map:match pattern="search">
           <map:generate type="customRequest"/>  -> create sax events
           <map:transform type="customQuery">
           </map:transform>
           <map:transform type="xslt" src="proto/xsl/documents.xsl"/>
           <map:serialize type="html"/>
        </map:match>

and I want :

1/  this first pipeline generate a DOM object in a session.


         <map:match pattern="search">
           <map:generate type="customRequest"/>  -> create sax events from 
a form
first possibility :
           <map:transform type="customQuery"/> -> get the result of the 
request and put it in a DOM into a session
second possibility :
           <map:transform type="writeDOMsession">
             <map:parameter name="dom-name" value="result"/>
             <map:parameter name="dom-root-element" value="docs"/> docs is 
the root element of the sax event which comes from the first transformer.
           </map:transform>
           <xml:serialize/>
         </map:match>


2/ this second pipeline get the DOM, so I could manipulate the result in 
the xsp page.
         <map:match pattern="xsppage">
           <map:generate type="serverpages" src="anyxsp.xsp"/> -> Get, I 
don't know how the DOM session object
           <map:transform type="xslt" src="demo/documents.xsl"/>
           <map:serialize/>
         </map:match>

Furthermore, I don't know how to link the two pipeline!

Hope that helps.


Lionel


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


how to parse an object

Posted by Lionel Crine <cr...@4dconcept.fr>.
I have a transformer in which I want to parse a "Document" Object :

I use org.apache.avalon.excalibur.xml.Parser : Is it possible to give an 
object to the parser ?


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


Re: object in a transformer

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 11.Mar.2003 -- 04:40 PM, Lionel Crine wrote:
> By the way, I have few more question
> 
> 1/Can I put anything in the session ?

Yes. Shouldn't be too big, though, unless you have enough memory.

> 2/In the xsp page, haow can I get attribute from the DOM object in the 
> session ?
> Like that : <xsp-session:get-attribute name="the_object_in_the DOM"/>

Retrieve the object and use e.g. jxpath or the dom java api on it.

> 3/If I want the xsp generator to retreive the DOMsessionelement from my 
> custom transfomer, should I use a resource ?

Wait - you want to generate your XSP from a session attribute? Doesn't
sound too good to me. Remember that it needs to be compiled everytime
it changes.... Apart from that, a source seems to be right.

Why don't you include the DOM from your XSP (or from a transformer). I
believe the session framework supports similar things. In addition,
the util logicsheet lets you include an object as XML (if it
implements certain interfaces, DOM should be OK).

	Chris.

Please follow up summarizing your problem and which suggested solution
/ information worked for you when you consider your problem
solved. Add "SUMMARY: " to the subject line. This will make FAQ
generation and searching the list easier. In addition, it makes
helping you more fun. Thank you.

And if you are really cool, add a page at http://wiki.cocoondev.org

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

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


Re: object in a transformer

Posted by Lionel Crine <cr...@4dconcept.fr>.
By the way, I have few more question

1/Can I put anything in the session ?

2/In the xsp page, haow can I get attribute from the DOM object in the 
session ?
Like that : <xsp-session:get-attribute name="the_object_in_the DOM"/>

3/If I want the xsp generator to retreive the DOMsessionelement from my 
custom transfomer, should I use a resource ?


At 14:51 11/03/2003 +0100, you wrote:
>On 11.Mar.2003 -- 02:46 PM, Lionel Crine wrote:
> > At 14:32 11/03/2003 +0100, you wrote:
> > >On 11.Mar.2003 -- 02:20 PM, Lionel Crine wrote:
> > >> I have a pipeline in which there is my custom transformer.
> > >> In this transformer I have a method which access to an XMLDB and get a
> > >> result object.
> > >>
> > >> I want my transformer to get the object (in a session) and get it to an
> > >xsp
> > >> page.
> > >>
> > >> Is it possible to do such a thing ?
> > >
> > >Sure. Just add the object to the session and retrieve it in your XSP
> > >e.g. using the session logicsheet. However, since the transformer runs
> > >in parallel to the XSP, they may not be within the same pipeline. IOW
> > >the XSP can reliably read the value only for a subsequent
> > >(i.e. different) request.
> > >
> > If I understand well, this is possible.
> >
> > But how can I add the object to the session. I think I should do that in
> > the transformer.
> > Can you tell me some more ?
>
>You need to get hold of the request object through the objectModel and
>the ObjectModelHelper. Get a session object from the request and set
>an attribute. Have a look at the transformers in the distribution for
>sample code.
>
>         Chris.
>--
>C h r i s t i a n       H a u l
>haul@informatik.tu-darmstadt.de
>     fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
>For additional commands, e-mail: cocoon-users-help@xml.apache.org


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


Re: object in a transformer

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 11.Mar.2003 -- 02:46 PM, Lionel Crine wrote:
> At 14:32 11/03/2003 +0100, you wrote:
> >On 11.Mar.2003 -- 02:20 PM, Lionel Crine wrote:
> >> I have a pipeline in which there is my custom transformer.
> >> In this transformer I have a method which access to an XMLDB and get a
> >> result object.
> >>
> >> I want my transformer to get the object (in a session) and get it to an 
> >xsp
> >> page.
> >>
> >> Is it possible to do such a thing ?
> >
> >Sure. Just add the object to the session and retrieve it in your XSP
> >e.g. using the session logicsheet. However, since the transformer runs
> >in parallel to the XSP, they may not be within the same pipeline. IOW
> >the XSP can reliably read the value only for a subsequent
> >(i.e. different) request.
> >
> If I understand well, this is possible.
> 
> But how can I add the object to the session. I think I should do that in 
> the transformer.
> Can you tell me some more ?

You need to get hold of the request object through the objectModel and
the ObjectModelHelper. Get a session object from the request and set
an attribute. Have a look at the transformers in the distribution for
sample code.

	Chris.
-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

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


Re: object in a transformer

Posted by Lionel Crine <cr...@4dconcept.fr>.
If I understand well, this is possible.

But how can I add the object to the session. I think I should do that in 
the transformer.
Can you tell me some more ?



At 14:32 11/03/2003 +0100, you wrote:
>On 11.Mar.2003 -- 02:20 PM, Lionel Crine wrote:
> > I have a pipeline in which there is my custom transformer.
> > In this transformer I have a method which access to an XMLDB and get a
> > result object.
> >
> > I want my transformer to get the object (in a session) and get it to an 
> xsp
> > page.
> >
> > Is it possible to do such a thing ?
>
>Sure. Just add the object to the session and retrieve it in your XSP
>e.g. using the session logicsheet. However, since the transformer runs
>in parallel to the XSP, they may not be within the same pipeline. IOW
>the XSP can reliably read the value only for a subsequent
>(i.e. different) request.
>
>         Chris.
>--
>C h r i s t i a n       H a u l
>haul@informatik.tu-darmstadt.de
>     fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
>For additional commands, e-mail: cocoon-users-help@xml.apache.org


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


Re: object in a transformer

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 11.Mar.2003 -- 02:20 PM, Lionel Crine wrote:
> I have a pipeline in which there is my custom transformer.
> In this transformer I have a method which access to an XMLDB and get a 
> result object.
> 
> I want my transformer to get the object (in a session) and get it to an xsp 
> page.
> 
> Is it possible to do such a thing ?

Sure. Just add the object to the session and retrieve it in your XSP
e.g. using the session logicsheet. However, since the transformer runs
in parallel to the XSP, they may not be within the same pipeline. IOW
the XSP can reliably read the value only for a subsequent
(i.e. different) request.

	Chris.
-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

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