You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Reuben Christie <rc...@decisiontech.com> on 2003/12/03 19:44:19 UTC

how to create XML DOM from SAX event

i have tried to extend the AbstractDOMTransformer class. and now i dont find
anyhelp for ,"how to work with transform method"? it takes Document argument
and returns the document.but which other methods do I need to implement. I m
new bie and have started writing transformer straight away so, please help
me.
here is my code.i want to now get the Document object of the sax event that
has come from generator into my transformer.where do I write my code ? do i
have toimplement startElement and endElement methods? or just carry on with
transformer method? and another question is,

what does this transformer passes to next componanat? SAX event or DOM ?


public class MyTransformer
	extends AbstractDOMTransformer
	implements Transformer, DOMBuilder.Listener, Composable, Disposable,
Recyclable {

	public void setup(
		SourceResolver resolver,
		Map objectModel,
		String src,
		Parameters par)
		throws ProcessingException, SAXException, IOException {
	}
	public void parameterize(Parameters parameters) throws ParameterException {
	}
	protected Document transform(Document doc) {
		doc = this.builder.getDocument();
		return doc;
	}
}


-----Original Message-----
From: Reuben Christie [mailto:rchristie@decisiontech.com]
Sent: Tuesday, December 02, 2003 11:58 AM
To: Cocoon Apache
Subject: how to create XML DOM from SAX event


Hi all, I m currently writing custom transformer  to connect to external
java program from cocoon. i m stuck here where i need to convert the sax
event into xml DOM object.
I use file generator to read from xml file and then pass it to the
transformer(my custome transformer) in pipeline in this transformer i want
to create the original xml file (anything, either string or DOM object). can
anybody help me out and throw me some ideas how to do that?
anyhelp will be grtly appriciated

thanks alot in advance
reuben


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


AW: how to create XML DOM from SAX event

Posted by Marco Rolappe <m_...@web.de>.
hi reuben,

when inheriting from the AbstractDOMTransformer you'd be overriding the
transform method, and there do the work you want to do; you're given a
Document (which represents the SAX events produced earlier in the pipeline),
which you can process in any way you like and at the end return it. the
Document you return will then be streamed as SAX events to the other
components in the pipeline.

> -----Ursprüngliche Nachricht-----
> Von: users-return-59455-m_rolappe=web.de@cocoon.apache.org
> [mailto:users-return-59455-m_rolappe=web.de@cocoon.apache.org]Im Auftrag
> von Reuben Christie
> Gesendet: Mittwoch, 3. Dezember 2003 19:44
> An: Cocoon Apache
> Betreff: how to create XML DOM from SAX event
>
>
>
> i have tried to extend the AbstractDOMTransformer class. and now
> i dont find
> anyhelp for ,"how to work with transform method"? it takes
> Document argument
> and returns the document.but which other methods do I need to
> implement. I m
> new bie and have started writing transformer straight away so, please help
> me.
> here is my code.i want to now get the Document object of the sax
> event that
> has come from generator into my transformer.where do I write my
> code ? do i
> have toimplement startElement and endElement methods? or just
> carry on with
> transformer method? and another question is,
>
> what does this transformer passes to next componanat? SAX event or DOM ?
>

<snip/>


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


Re: how to create XML DOM from SAX event

Posted by Lionel Crine <cr...@4dconcept.fr>.
Because If I do not write it, I don't get the Document coming from the 
pipeline.



At 10:37 11/12/2003 +0100, you wrote:
>Lionel Crine wrote:
>
>>/**
>>  * Get the DOM return it in the flow.
>>  */
>>protected Document transform(Document doc) {
>>doc = this.builder.getDocument(); //get the doc as DOM
>>doc = this.addDmidref(doc); //any method you want to use.
>>return doc;
>>}
>
>In above code, why do you set doc to this.builder.getDocument()? I thought 
>the document was already handed to you as DOM already so why not use the 
>reference passed in the function?
>
>Jorg
>
>>
>>Lionel
>>
>>At 13:44 03/12/2003 -0500, you wrote:
>>
>>>i have tried to extend the AbstractDOMTransformer class. and now i dont find
>>>anyhelp for ,"how to work with transform method"? it takes Document argument
>>>and returns the document.but which other methods do I need to implement. I m
>>>new bie and have started writing transformer straight away so, please help
>>>me.
>>>here is my code.i want to now get the Document object of the sax event that
>>>has come from generator into my transformer.where do I write my code ? do i
>>>have toimplement startElement and endElement methods? or just carry on with
>>>transformer method? and another question is,
>>>
>>>what does this transformer passes to next componanat? SAX event or DOM ?
>>>
>>>
>>>public class MyTransformer
>>>         extends AbstractDOMTransformer
>>>         implements Transformer, DOMBuilder.Listener, Composable, 
>>> Disposable,
>>>Recyclable {
>>>
>>>         public void setup(
>>>                 SourceResolver resolver,
>>>                 Map objectModel,
>>>                 String src,
>>>                 Parameters par)
>>>                 throws ProcessingException, SAXException, IOException {
>>>         }
>>>         public void parameterize(Parameters parameters) throws 
>>> ParameterException {
>>>         }
>>>         protected Document transform(Document doc) {
>>>                 doc = this.builder.getDocument();
>>>                 return doc;
>>>         }
>>>}
>>>
>>>
>>>-----Original Message-----
>>>From: Reuben Christie [mailto:rchristie@decisiontech.com]
>>>Sent: Tuesday, December 02, 2003 11:58 AM
>>>To: Cocoon Apache
>>>Subject: how to create XML DOM from SAX event
>>>
>>>
>>>Hi all, I m currently writing custom transformer  to connect to external
>>>java program from cocoon. i m stuck here where i need to convert the sax
>>>event into xml DOM object.
>>>I use file generator to read from xml file and then pass it to the
>>>transformer(my custome transformer) in pipeline in this transformer i want
>>>to create the original xml file (anything, either string or DOM object). can
>>>anybody help me out and throw me some ideas how to do that?
>>>anyhelp will be grtly appriciated
>>>
>>>thanks alot in advance
>>>reuben
>>>
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>>For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>Lionel CRINE
>>Ingénieur Systèmes documentaires
>>Société : 4DConcept
>>22 rue Etienne de Jouy 78353 JOUY EN JOSAS
>>Tel : 01.34.58.70.70 Fax : 01.39.58.70.70
>>
>>---------------------------------------------------------------------
>>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

Lionel CRINE
Ingénieur Systèmes documentaires
Société : 4DConcept
22 rue Etienne de Jouy 78353 JOUY EN JOSAS
Tel : 01.34.58.70.70 Fax : 01.39.58.70.70


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


Re: how to create XML DOM from SAX event

Posted by Jorg Heymans <jh...@domek.be>.
Lionel Crine wrote:

> 
> /**
>  * Get the DOM return it in the flow.
>  */
> protected Document transform(Document doc) {
> doc = this.builder.getDocument(); //get the doc as DOM
> doc = this.addDmidref(doc); //any method you want to use.
> return doc;
> }

In above code, why do you set doc to this.builder.getDocument()? I 
thought the document was already handed to you as DOM already so why not 
use the reference passed in the function?

Jorg

> 
> 
> 
> Lionel
> 
> 
> At 13:44 03/12/2003 -0500, you wrote:
> 
>> i have tried to extend the AbstractDOMTransformer class. and now i 
>> dont find
>> anyhelp for ,"how to work with transform method"? it takes Document 
>> argument
>> and returns the document.but which other methods do I need to 
>> implement. I m
>> new bie and have started writing transformer straight away so, please 
>> help
>> me.
>> here is my code.i want to now get the Document object of the sax event 
>> that
>> has come from generator into my transformer.where do I write my code ? 
>> do i
>> have toimplement startElement and endElement methods? or just carry on 
>> with
>> transformer method? and another question is,
>>
>> what does this transformer passes to next componanat? SAX event or DOM ?
>>
>>
>> public class MyTransformer
>>         extends AbstractDOMTransformer
>>         implements Transformer, DOMBuilder.Listener, Composable, 
>> Disposable,
>> Recyclable {
>>
>>         public void setup(
>>                 SourceResolver resolver,
>>                 Map objectModel,
>>                 String src,
>>                 Parameters par)
>>                 throws ProcessingException, SAXException, IOException {
>>         }
>>         public void parameterize(Parameters parameters) throws 
>> ParameterException {
>>         }
>>         protected Document transform(Document doc) {
>>                 doc = this.builder.getDocument();
>>                 return doc;
>>         }
>> }
>>
>>
>> -----Original Message-----
>> From: Reuben Christie [mailto:rchristie@decisiontech.com]
>> Sent: Tuesday, December 02, 2003 11:58 AM
>> To: Cocoon Apache
>> Subject: how to create XML DOM from SAX event
>>
>>
>> Hi all, I m currently writing custom transformer  to connect to external
>> java program from cocoon. i m stuck here where i need to convert the sax
>> event into xml DOM object.
>> I use file generator to read from xml file and then pass it to the
>> transformer(my custome transformer) in pipeline in this transformer i 
>> want
>> to create the original xml file (anything, either string or DOM 
>> object). can
>> anybody help me out and throw me some ideas how to do that?
>> anyhelp will be grtly appriciated
>>
>> thanks alot in advance
>> reuben
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
> Lionel CRINE
> Ingénieur Systèmes documentaires
> Société : 4DConcept
> 22 rue Etienne de Jouy 78353 JOUY EN JOSAS
> Tel : 01.34.58.70.70 Fax : 01.39.58.70.70
> 
> 
> ---------------------------------------------------------------------
> 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: how to create XML DOM from SAX event

Posted by Lionel Crine <cr...@4dconcept.fr>.
Here is one of my examples :


public class TransformerAddDmidref extends AbstractDOMTransformer {
private String dmfamilyref;

/**
  * Set the <code>SourceResolver</code>, objectModel <code>Map</code>,
  * the source and sitemap <code>Parameters</code> used to process the request.
  *
  * If you wish to process the parameters, override this method, call
  * <code>super()</code> and then add your code.
  */
public void setup(SourceResolver resolver, Map objectModel, String src, 
Parameters par) throws ProcessingException, SAXException, IOException {
super.setup(resolver, objectModel, src, par);
}

/**
  * Get the DOM return it in the flow.
  */
protected Document transform(Document doc) {
doc = this.builder.getDocument(); //get the doc as DOM
doc = this.addDmidref(doc); //any method you want to use.
return doc;
}



Lionel


At 13:44 03/12/2003 -0500, you wrote:

>i have tried to extend the AbstractDOMTransformer class. and now i dont find
>anyhelp for ,"how to work with transform method"? it takes Document argument
>and returns the document.but which other methods do I need to implement. I m
>new bie and have started writing transformer straight away so, please help
>me.
>here is my code.i want to now get the Document object of the sax event that
>has come from generator into my transformer.where do I write my code ? do i
>have toimplement startElement and endElement methods? or just carry on with
>transformer method? and another question is,
>
>what does this transformer passes to next componanat? SAX event or DOM ?
>
>
>public class MyTransformer
>         extends AbstractDOMTransformer
>         implements Transformer, DOMBuilder.Listener, Composable, Disposable,
>Recyclable {
>
>         public void setup(
>                 SourceResolver resolver,
>                 Map objectModel,
>                 String src,
>                 Parameters par)
>                 throws ProcessingException, SAXException, IOException {
>         }
>         public void parameterize(Parameters parameters) throws 
> ParameterException {
>         }
>         protected Document transform(Document doc) {
>                 doc = this.builder.getDocument();
>                 return doc;
>         }
>}
>
>
>-----Original Message-----
>From: Reuben Christie [mailto:rchristie@decisiontech.com]
>Sent: Tuesday, December 02, 2003 11:58 AM
>To: Cocoon Apache
>Subject: how to create XML DOM from SAX event
>
>
>Hi all, I m currently writing custom transformer  to connect to external
>java program from cocoon. i m stuck here where i need to convert the sax
>event into xml DOM object.
>I use file generator to read from xml file and then pass it to the
>transformer(my custome transformer) in pipeline in this transformer i want
>to create the original xml file (anything, either string or DOM object). can
>anybody help me out and throw me some ideas how to do that?
>anyhelp will be grtly appriciated
>
>thanks alot in advance
>reuben
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org

Lionel CRINE
Ingénieur Systèmes documentaires
Société : 4DConcept
22 rue Etienne de Jouy 78353 JOUY EN JOSAS
Tel : 01.34.58.70.70 Fax : 01.39.58.70.70


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