Re: Dom Transformer
I have tags with id's like: some-section-tag id='109876_n00069 And those ids are used for links inside the document. They are linked from different sections. I like to transform the links and the ids to something that makes sense. Like, xref href=the-section-title-with-dashes-only My Link Label/xref And The anchor some-section-tag id='the-section-title-with-dashes-only I think this can be done is Stax, xslt or Sax, however, I am trying to do it in a clean way without any hacks. Do you have any suggestion ?? On Fri, Mar 15, 2013 at 2:18 PM, gelo1234 gelo1...@gmail.com wrote: The question is WHY? you want DOM transformation in Cocoon environment ? Greetings, -Greg 2013/3/15 Mansour Al Akeel mansour.alak...@gmail.com I know this may sound strange, but I like to create a transformation with DOM. I was able to see Stax and Sax transformation. I was not able to see one for DOM. Any advice ?? Examples ?? - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org
Re: Dom Transformer
Jos, thank you. I though about this. The problem is, the documents I am processing had to go through a pipeline processing before I need to use DOM transformation on them. So a generator is not an option, and I am using C3. On Fri, Mar 15, 2013 at 2:58 PM, Jos Snellings jos.snelli...@upperware.biz wrote: You can, within a generator class, (C3), or within an xsp (C 2). Sometimes such things come in handy. If you mean, configure one from the sitemap, I see no uses. Cheers, Jos On Fri, Mar 15, 2013 at 7:05 PM, Mansour Al Akeel mansour.alak...@gmail.com wrote: I know this may sound strange, but I like to create a transformation with DOM. I was able to see Stax and Sax transformation. I was not able to see one for DOM. Any advice ?? Examples ?? - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org -- All generous minds have a horror of what are commonly called Facts. They are the brute beasts of the intellectual domain. -- Thomas Hobbes - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org
Re: Dom Transformer
The question is WHY you want to use DOM is still valid. C (2 or 3) uses SAX or StaX per default and you can use it in a clean way. I see no reason to use DOM. Greetings, -Greg 2013/3/15 Mansour Al Akeel mansour.alak...@gmail.com I have tags with id's like: some-section-tag id='109876_n00069 And those ids are used for links inside the document. They are linked from different sections. I like to transform the links and the ids to something that makes sense. Like, xref href=the-section-title-with-dashes-only My Link Label/xref And The anchor some-section-tag id='the-section-title-with-dashes-only I think this can be done is Stax, xslt or Sax, however, I am trying to do it in a clean way without any hacks. Do you have any suggestion ?? On Fri, Mar 15, 2013 at 2:18 PM, gelo1234 gelo1...@gmail.com wrote: The question is WHY? you want DOM transformation in Cocoon environment ? Greetings, -Greg 2013/3/15 Mansour Al Akeel mansour.alak...@gmail.com I know this may sound strange, but I like to create a transformation with DOM. I was able to see Stax and Sax transformation. I was not able to see one for DOM. Any advice ?? Examples ?? - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org
RE: Dom Transformer
Exactly… I don’t have the full picture here but if you provide a small input file and expected output file we might come up with an easier solution. I still am not seeing why XSLT can’t get the job done but I hope your input will make this obvious. Robby From: gelo1234 [mailto:gelo1...@gmail.com] Sent: Friday, March 15, 2013 8:02 PM To: users@cocoon.apache.org Subject: Re: Dom Transformer The question is WHY you want to use DOM is still valid. C (2 or 3) uses SAX or StaX per default and you can use it in a clean way. I see no reason to use DOM. Greetings, -Greg 2013/3/15 Mansour Al Akeel mansour.alak...@gmail.commailto:mansour.alak...@gmail.com I have tags with id's like: some-section-tag id='109876_n00069 And those ids are used for links inside the document. They are linked from different sections. I like to transform the links and the ids to something that makes sense. Like, xref href=the-section-title-with-dashes-only My Link Label/xref And The anchor some-section-tag id='the-section-title-with-dashes-only I think this can be done is Stax, xslt or Sax, however, I am trying to do it in a clean way without any hacks. Do you have any suggestion ?? On Fri, Mar 15, 2013 at 2:18 PM, gelo1234 gelo1...@gmail.commailto:gelo1...@gmail.com wrote: The question is WHY? you want DOM transformation in Cocoon environment ? Greetings, -Greg 2013/3/15 Mansour Al Akeel mansour.alak...@gmail.commailto:mansour.alak...@gmail.com I know this may sound strange, but I like to create a transformation with DOM. I was able to see Stax and Sax transformation. I was not able to see one for DOM. Any advice ?? Examples ?? - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.orgmailto:users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.orgmailto:users-h...@cocoon.apache.org - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.orgmailto:users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.orgmailto:users-h...@cocoon.apache.org
Re: Dom Transformer
Not sure what your usage is, Mansour. If your program has to generate references to things that 'yet have to come' in the input stream, of course you get quickly into thinking 'DOM'-wise. - I believe Stax can bring outcome, but no experience with this. - I once wrote a 'SAX-recorder', so somefilter that records SAX-elements, but do not remember exactly what problem that solved, just that it worked. - it is possible to trap SAX-events and feed them into a JDom object. (I mean, if nothing else works). Cheers, Jos On Fri, Mar 15, 2013 at 8:01 PM, Mansour Al Akeel mansour.alak...@gmail.com wrote: Jos, thank you. I though about this. The problem is, the documents I am processing had to go through a pipeline processing before I need to use DOM transformation on them. So a generator is not an option, and I am using C3. On Fri, Mar 15, 2013 at 2:58 PM, Jos Snellings jos.snelli...@upperware.biz wrote: You can, within a generator class, (C3), or within an xsp (C 2). Sometimes such things come in handy. If you mean, configure one from the sitemap, I see no uses. Cheers, Jos On Fri, Mar 15, 2013 at 7:05 PM, Mansour Al Akeel mansour.alak...@gmail.com wrote: I know this may sound strange, but I like to create a transformation with DOM. I was able to see Stax and Sax transformation. I was not able to see one for DOM. Any advice ?? Examples ?? - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org -- All generous minds have a horror of what are commonly called Facts. They are the brute beasts of the intellectual domain. -- Thomas Hobbes - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org -- All generous minds have a horror of what are commonly called Facts. They are the brute beasts of the intellectual domain. -- Thomas Hobbes http://www.brainyquote.com/quotes/quotes/t/thomashobb118630.html
Re: Dom Transformer
2013/3/15 Mansour Al Akeel mansour.alak...@gmail.com I have tags with id's like: some-section-tag id='109876_n00069 And those ids are used for links inside the document. They are linked from different sections. I like to transform the links and the ids to something that makes sense. Like, xref href=the-section-title-with-dashes-only My Link Label/xref And The anchor some-section-tag id='the-section-title-with-dashes-only I think this can be done is Stax, xslt or Sax, however, I am trying to do it in a clean way without any hacks. Do you have any suggestion ?? You can do it whithout any hack with all the ways, sax, stax and xslt. XSLT: sitemap.xmap map:transform src=resources/xslt/page2html.xsl map:parameter name=language value={locale:1}/map:parameter name=dojoVersion value={global:ch.sobu.dojo.version}/map:parameter name=staticBaseUri value={global:proxy.static}/map:parameter name=publicBaseUri value={global:proxy.public}/map:parameter name=env value={global:ch.sobu.build.env}/map:parameter name=version value={global:ch.sobu.build.version}//map:transform On Fri, Mar 15, 2013 at 2:18 PM, gelo1234 gelo1...@gmail.com wrote: The question is WHY? you want DOM transformation in Cocoon environment ? Greetings, -Greg 2013/3/15 Mansour Al Akeel mansour.alak...@gmail.com I know this may sound strange, but I like to create a transformation with DOM. I was able to see Stax and Sax transformation. I was not able to see one for DOM. Any advice ?? Examples ?? - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org
Re: Dom Transformer
Seems reasonable. Although its a bit awkward idea. Simplicity is the key ;) Greetings, -Greg 2013/3/15 Jos Snellings jos.snelli...@upperware.biz Not sure what your usage is, Mansour. If your program has to generate references to things that 'yet have to come' in the input stream, of course you get quickly into thinking 'DOM'-wise. - I believe Stax can bring outcome, but no experience with this. - I once wrote a 'SAX-recorder', so somefilter that records SAX-elements, but do not remember exactly what problem that solved, just that it worked. - it is possible to trap SAX-events and feed them into a JDom object. (I mean, if nothing else works). Cheers, Jos On Fri, Mar 15, 2013 at 8:01 PM, Mansour Al Akeel mansour.alak...@gmail.com wrote: Jos, thank you. I though about this. The problem is, the documents I am processing had to go through a pipeline processing before I need to use DOM transformation on them. So a generator is not an option, and I am using C3. On Fri, Mar 15, 2013 at 2:58 PM, Jos Snellings jos.snelli...@upperware.biz wrote: You can, within a generator class, (C3), or within an xsp (C 2). Sometimes such things come in handy. If you mean, configure one from the sitemap, I see no uses. Cheers, Jos On Fri, Mar 15, 2013 at 7:05 PM, Mansour Al Akeel mansour.alak...@gmail.com wrote: I know this may sound strange, but I like to create a transformation with DOM. I was able to see Stax and Sax transformation. I was not able to see one for DOM. Any advice ?? Examples ?? - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org -- All generous minds have a horror of what are commonly called Facts. They are the brute beasts of the intellectual domain. -- Thomas Hobbes - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org -- All generous minds have a horror of what are commonly called Facts. They are the brute beasts of the intellectual domain. -- Thomas Hobbes http://www.brainyquote.com/quotes/quotes/t/thomashobb118630.html
Re: Dom Transformer
2013/3/15 Javier Puerto jpue...@gmail.com 2013/3/15 Mansour Al Akeel mansour.alak...@gmail.com I have tags with id's like: some-section-tag id='109876_n00069 And those ids are used for links inside the document. They are linked from different sections. I like to transform the links and the ids to something that makes sense. Like, xref href=the-section-title-with-dashes-only My Link Label/xref And The anchor some-section-tag id='the-section-title-with-dashes-only I think this can be done is Stax, xslt or Sax, however, I am trying to do it in a clean way without any hacks. Do you have any suggestion ?? You can do it whithout any hack with all the ways, sax, stax and xslt. XSLT: sitemap.xmap Sorry, the message was sent by error before the example was finished. :) On Fri, Mar 15, 2013 at 2:18 PM, gelo1234 gelo1...@gmail.com wrote: The question is WHY? you want DOM transformation in Cocoon environment ? Greetings, -Greg 2013/3/15 Mansour Al Akeel mansour.alak...@gmail.com I know this may sound strange, but I like to create a transformation with DOM. I was able to see Stax and Sax transformation. I was not able to see one for DOM. Any advice ?? Examples ?? - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org
Re: Dom Transformer
2013/3/15 Mansour Al Akeel mansour.alak...@gmail.com I have tags with id's like: some-section-tag id='109876_n00069 And those ids are used for links inside the document. They are linked from different sections. I like to transform the links and the ids to something that makes sense. Like, xref href=the-section-title-with-dashes-only My Link Label/xref And The anchor some-section-tag id='the-section-title-with-dashes-only I think this can be done is Stax, xslt or Sax, however, I am trying to do it in a clean way without any hacks. Do you have any suggestion ?? XSLT sample: You can add the following transformation to oyur pipeline sitemap.xmap: map:transform src=resources/xslt/uuid2title.xsl/ And create an xslt file that maches the elements you want to change uuid2title.xsl xsl:template match=some-section-tag/@id xsl:attribute name=id xsl:value-of select=replace([your tile node xpath], , )/ /xsl:attribute /xsl:template I hope that helps, I've not tested it. With SAX and StAX it's similar but written in java, you have to locate the element you are looking for and replace the attribute with the new one. Most times XSLT is enough, SAX and StAX is used if you have to do some business logic. DOM is not good idea because is not event based and Cocoon pipeline is based on XML events so to work with DOM you have to do double work, transform to DOM and generate SAX or StAX events later to hook the pipeline. Salu2. On Fri, Mar 15, 2013 at 2:18 PM, gelo1234 gelo1...@gmail.com wrote: The question is WHY? you want DOM transformation in Cocoon environment ? Greetings, -Greg 2013/3/15 Mansour Al Akeel mansour.alak...@gmail.com I know this may sound strange, but I like to create a transformation with DOM. I was able to see Stax and Sax transformation. I was not able to see one for DOM. Any advice ?? Examples ?? - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org
Re: Dom Transformer
On Fri, Mar 15, 2013 at 02:58:37PM -0400, Mansour Al Akeel wrote: I have tags with id's like: some-section-tag id='109876_n00069 And those ids are used for links inside the document. They are linked from different sections. I like to transform the links and the ids to something that makes sense. Like, xref href=the-section-title-with-dashes-only My Link Label/xref And The anchor some-section-tag id='the-section-title-with-dashes-only I think this can be done is Stax, xslt or Sax, however, I am trying to do it in a clean way without any hacks. Do you have any suggestion ?? I well understand the appeal of keeping the whole document around for random access. :-) But have you considered xsl:key? It sound like you want to accumulate a symbol table and fetch useful properties of the symbols when you see them again. I'm only brainstorming here. I haven't yet used xsl:key myself. But if I don't expose my ignorance once in a while, I'll never learn. :-) If you find my suggestion helpful, I'd like to see how you used it. -- Mark H. Wood, Lead System Programmer mw...@iupui.edu There's an app for that: your browser pgpDlNmzRGMDQ.pgp Description: PGP signature
Re: Custom DOM transformer
Hello, Thanks a lot for your answers which helped me to understand my problem. It was finally not a Cocoon usage problem like I believed too long, I had a releaseConnection on my PostMethod before logging the resulting body on the client side. So the http response body was ever null. In fact, the simple following sitemap code works fine (to get the post body and send it again) : map:pipeline map:match pattern=tentative map:generate type=stream map:parameter name=defaultContentType value=text/xml / /map:generate map:serialize type=xml/ /map:match /map:pipeline Thank again, Jean-Claude 2007/11/19, [EMAIL PROTECTED] [EMAIL PROTECTED]: You have proven the problem is not in the custom DOMTransformer. Warrell suggests using the Request Generator. I generate form data using the Server Pages Generator with an XSP. I wrote this when I was very new to Cocoon. It works, but I would be very interested in a debate about the best algorithm for reading POST data. http://svn.apache.org/repos/asf/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/form/post.xsp Instructions: http://svn.apache.org/repos/asf/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/form/module.xml If you need more assistance, start a new thread with a more appropriate subject to interest non-Java-writing ML readers scared by the current title. solprovider On 11/19/07, Jean-Claude Vogel [EMAIL PROTECTED] wrote: Thank you, effectively it was just a mistake during my drag and drop to write my email. The true code is : map:pipeline map:match pattern=tentative map:generate type=stream map:parameter name=defaultContentType value=text/xml/ /map:generate map:transform type=testTransformer / map:serialize type=xml/ /map:match /map:pipeline My sitemap contains other pipelines which I don't show here, that's why I have a matcher. I tried to remove the transformer to keep just : map:pipeline map:match pattern=tentative map:generate type=stream map:parameter name=defaultContentType value=text/xml/ /map:generate map:serialize type=xml/ /map:match /map:pipeline Effectively, I have the same problem : no XML stream in the http response. Like said before, I am sure that the body of my incoming HTTP request contains an XML stream (when I let the testTransformer in the pipe I can log the incoming XML stream). I am not able to understand where is my mistake and why the HTTP response body stays empty. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Custom DOM transformer
Thank you, effectively it was just a mistake during my drag and drop to write my email. The true code is : map:pipeline map:match pattern=tentative map:generate type=stream map:parameter name=defaultContentType value=text/xml/ /map:generate map:transform type=testTransformer / map:serialize type=xml/ /map:match /map:pipeline My sitemap contains other pipelines which I don't show here, that's why I have a matcher. I tried to remove the transformer to keep just : map:pipeline map:match pattern=tentative map:generate type=stream map:parameter name=defaultContentType value=text/xml/ /map:generate map:serialize type=xml/ /map:match /map:pipeline Effectively, I have the same problem : no XML stream in the http response. Like said before, I am sure that the body of my incoming HTTP request contains an XML stream (when I let the testTransformer in the pipe I can log the incoming XML stream). I am not able to understand where is my mistake and why the HTTP response body stays empty. 2007/11/16, [EMAIL PROTECTED] [EMAIL PROTECTED]: The two examples are functionally equivalent. Both pipelines would error without the pattern=tentative match: the former because no pipeline match is found and the latter because no Serializer is called. The map:match element is irrelevant because the match must be assumed and no numbered parameters are being set. This would be fine as the concerned extract: map:pipeline map:generate type=stream map:parameter name=defaultContentType value=text/xml/ /map:generate map:transform type=testTransformer / map:serialize type=xml/ /map:pipeline We should assume the match is for code outside the current concern and remained because the OP forgot to remove it as irrelevant. The mistake was providing too much code. solprovider On 11/16/07, warrell harries [EMAIL PROTECTED] wrote: Surely some mistake (probably a typo) but your pipeline should be :- map:pipeline map:match pattern=tentative map:generate type=stream map:parameter name=defaultContentType value=text/xml/ /map:generate map:transform type=testTransformer / map:serialize type=xml/ /map:match /map:pipeline On 16/11/2007, Jean-Claude Vogel [EMAIL PROTECTED] wrote: Here is the concerned extract of my sitemap : map:pipeline map:generate type=stream map:parameter name=defaultContentType value=text/xml/ /map:generate map:match pattern=tentative map:transform type=testTransformer / map:serialize type=xml/ /map:match /map:pipeline - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Custom DOM transformer
You have proven the problem is not in the custom DOMTransformer. Warrell suggests using the Request Generator. I generate form data using the Server Pages Generator with an XSP. I wrote this when I was very new to Cocoon. It works, but I would be very interested in a debate about the best algorithm for reading POST data. http://svn.apache.org/repos/asf/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/form/post.xsp Instructions: http://svn.apache.org/repos/asf/lenya/branches/revolution/1.3.x/src/webapp/lenya/modules/form/module.xml If you need more assistance, start a new thread with a more appropriate subject to interest non-Java-writing ML readers scared by the current title. solprovider On 11/19/07, Jean-Claude Vogel [EMAIL PROTECTED] wrote: Thank you, effectively it was just a mistake during my drag and drop to write my email. The true code is : map:pipeline map:match pattern=tentative map:generate type=stream map:parameter name=defaultContentType value=text/xml/ /map:generate map:transform type=testTransformer / map:serialize type=xml/ /map:match /map:pipeline My sitemap contains other pipelines which I don't show here, that's why I have a matcher. I tried to remove the transformer to keep just : map:pipeline map:match pattern=tentative map:generate type=stream map:parameter name=defaultContentType value=text/xml/ /map:generate map:serialize type=xml/ /map:match /map:pipeline Effectively, I have the same problem : no XML stream in the http response. Like said before, I am sure that the body of my incoming HTTP request contains an XML stream (when I let the testTransformer in the pipe I can log the incoming XML stream). I am not able to understand where is my mistake and why the HTTP response body stays empty. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Custom DOM transformer
Hello guys, I would like to write my own dom transformer. So I simply wrote the following in order to get firstly an identity transformer : public class TestTransformer extends AbstractDOMTransformer { private Request request; public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException { super.setup(resolver, objectModel, src, par); } public Document transform(Document document) { // When I log here I see that document contains what I want it to contain return document; } } To test I send an HTTP post request with an XML in its body, but I my HTTP request response body is desesperatly NULL. I tried to log what happens in the transform method and I can see in my XML body sent by HTTP. The post response is ever empty. What's wrong in my code please ?
Re: Custom DOM transformer
Remove the map:transform type=testTransformer / line to verify the problem is in the transformer. Make certain everything worked without the transformer, then add the line and see if the problem recurs. solprovider On 11/16/07, Jean-Claude Vogel [EMAIL PROTECTED] wrote: Here is the concerned extract of my sitemap : map:pipeline map:generate type=stream map:parameter name=defaultContentType value=text/xml/ /map:generate map:match pattern=tentative map:transform type=testTransformer / map:serialize type=xml/ /map:match /map:pipeline Here, a part of the applicationContext.xml (Spring declaration of my transformer) : bean name=testService class= org.springframework.transaction.interceptor.TransactionProxyFactoryBean property name=transactionManager ref bean=maTransactionManager / /property property name=target bean class=.TestService property name=maxml2ObjectsService ref bean=maxml2ObjectsService / /property property name=serviceProgramsService ref bean=serviceProgramsService / /property /bean /property property name=transactionAttributes props prop key=testPROPAGATION_REQUIRED/prop /props /property /bean bean id=testTransformer name=org.apache.cocoon.transformation.Transformer/testTransformer scope=prototype class=.TestTransformer property name=testService ref bean=testService/ /property /bean What I had in my transformer to log the XML stream (wich is effectively received and logged by the transformer) : public Document transform(Document document) { try { DOMSource domSource = new DOMSource(document); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.transform(domSource, result); log.debug(TRANSFORMATION: + writer.toString ()); } catch (TransformerConfigurationException e) { e.printStackTrace(); } catch (TransformerException e) { e.printStackTrace (); } return document; } I use HttpClient to send the post request containing the XML stream and to get the XML stream received (unhappily NULL) : HttpClient client = new HttpClient(); StringBuffer newUrl = new StringBuffer(); newUrl.append(url); PostMethod method = new PostMethod(newUrl.toString()); method.setRequestBody(new FileInputStream(xmlFile)); String xml = post.getResponseBodyAsString(); System.out.println(Exported virtual XML : + maxml); // Here the response is NULL Thank for your help 2007/11/16, warrell harries [EMAIL PROTECTED]: Hi Jean-Claude, What generator are you using in your pipeline match? Can you show us the sitemap? You would need to use the Request generator or another one that 'loads' the pipeline with the contents of the HTTP Request. Cheers On 16/11/2007, Jean-Claude Vogel [EMAIL PROTECTED] wrote: Hello guys, I would like to write my own dom transformer. So I simply wrote the following in order to get firstly an identity transformer : public class TestTransformer extends AbstractDOMTransformer { private Request request; public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException { super.setup(resolver, objectModel, src, par); } public Document transform(Document document) { // When I log here I see that document contains what I want it to contain return document; } } To test I send an HTTP post request with an XML in its body, but I my HTTP request response body is desesperatly NULL. I tried to log what happens in the transform method and I can see in my XML body sent by HTTP. The post response is ever empty. What's wrong in my code please ? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Custom DOM transformer
Here is the concerned extract of my sitemap : map:pipeline map:generate type=stream map:parameter name=defaultContentType value=text/xml/ /map:generate map:match pattern=tentative map:transform type=testTransformer / map:serialize type=xml/ /map:match /map:pipeline Here, a part of the applicationContext.xml (Spring declaration of my transformer) : bean name=testService class= org.springframework.transaction.interceptor.TransactionProxyFactoryBean property name=transactionManager ref bean=maTransactionManager / /property property name=target bean class=.TestService property name=maxml2ObjectsService ref bean=maxml2ObjectsService / /property property name=serviceProgramsService ref bean=serviceProgramsService / /property /bean /property property name=transactionAttributes props prop key=testPROPAGATION_REQUIRED/prop /props /property /bean bean id=testTransformer name=org.apache.cocoon.transformation.Transformer/testTransformer scope=prototype class=.TestTransformer property name=testService ref bean=testService/ /property /bean What I had in my transformer to log the XML stream (wich is effectively received and logged by the transformer) : public Document transform(Document document) { try { DOMSource domSource = new DOMSource(document); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.transform(domSource, result); log.debug(TRANSFORMATION: + writer.toString()); } catch (TransformerConfigurationException e) { e.printStackTrace(); } catch (TransformerException e) { e.printStackTrace(); } return document; } I use HttpClient to send the post request containing the XML stream and to get the XML stream received (unhappily NULL) : HttpClient client = new HttpClient(); StringBuffer newUrl = new StringBuffer(); newUrl.append(url); PostMethod method = new PostMethod(newUrl.toString()); method.setRequestBody(new FileInputStream(xmlFile)); String xml = post.getResponseBodyAsString(); System.out.println(Exported virtual XML : + maxml); // Here the response is NULL Thank for your help 2007/11/16, warrell harries [EMAIL PROTECTED]: Hi Jean-Claude, What generator are you using in your pipeline match? Can you show us the sitemap? You would need to use the Request generator or another one that 'loads' the pipeline with the contents of the HTTP Request. Cheers On 16/11/2007, Jean-Claude Vogel [EMAIL PROTECTED] wrote: Hello guys, I would like to write my own dom transformer. So I simply wrote the following in order to get firstly an identity transformer : public class TestTransformer extends AbstractDOMTransformer { private Request request; public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException { super.setup(resolver, objectModel, src, par); } public Document transform(Document document) { // When I log here I see that document contains what I want it to contain return document; } } To test I send an HTTP post request with an XML in its body, but I my HTTP request response body is desesperatly NULL. I tried to log what happens in the transform method and I can see in my XML body sent by HTTP. The post response is ever empty. What's wrong in my code please ?
Re: Custom DOM transformer
Surely some mistake (probably a typo) but your pipeline should be :- map:pipeline map:match pattern=tentative map:generate type=stream map:parameter name=defaultContentType value=text/xml/ /map:generate map:transform type=testTransformer / map:serialize type=xml/ /map:match /map:pipeline On 16/11/2007, Jean-Claude Vogel [EMAIL PROTECTED] wrote: Here is the concerned extract of my sitemap : map:pipeline map:generate type=stream map:parameter name=defaultContentType value=text/xml/ /map:generate map:match pattern=tentative map:transform type=testTransformer / map:serialize type=xml/ /map:match /map:pipeline
Re: Custom DOM transformer
Hi Jean-Claude, What generator are you using in your pipeline match? Can you show us the sitemap? You would need to use the Request generator or another one that 'loads' the pipeline with the contents of the HTTP Request. Cheers On 16/11/2007, Jean-Claude Vogel [EMAIL PROTECTED] wrote: Hello guys, I would like to write my own dom transformer. So I simply wrote the following in order to get firstly an identity transformer : public class TestTransformer extends AbstractDOMTransformer { private Request request; public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException { super.setup(resolver, objectModel, src, par); } public Document transform(Document document) { // When I log here I see that document contains what I want it to contain return document; } } To test I send an HTTP post request with an XML in its body, but I my HTTP request response body is desesperatly NULL. I tried to log what happens in the transform method and I can see in my XML body sent by HTTP. The post response is ever empty. What's wrong in my code please ?
Re: Custom DOM transformer
The two examples are functionally equivalent. Both pipelines would error without the pattern=tentative match: the former because no pipeline match is found and the latter because no Serializer is called. The map:match element is irrelevant because the match must be assumed and no numbered parameters are being set. This would be fine as the concerned extract: map:pipeline map:generate type=stream map:parameter name=defaultContentType value=text/xml/ /map:generate map:transform type=testTransformer / map:serialize type=xml/ /map:pipeline We should assume the match is for code outside the current concern and remained because the OP forgot to remove it as irrelevant. The mistake was providing too much code. solprovider On 11/16/07, warrell harries [EMAIL PROTECTED] wrote: Surely some mistake (probably a typo) but your pipeline should be :- map:pipeline map:match pattern=tentative map:generate type=stream map:parameter name=defaultContentType value=text/xml/ /map:generate map:transform type=testTransformer / map:serialize type=xml/ /map:match /map:pipeline On 16/11/2007, Jean-Claude Vogel [EMAIL PROTECTED] wrote: Here is the concerned extract of my sitemap : map:pipeline map:generate type=stream map:parameter name=defaultContentType value=text/xml/ /map:generate map:match pattern=tentative map:transform type=testTransformer / map:serialize type=xml/ /map:match /map:pipeline - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]