Hello Eric,

First of all I think it is strange to have a transformer sort of act like a 
generator, since you try to add a block of xml (I do suppose you have an xml 
structure where you want the block of xml added to).

Anyway, probably you only know what you want to fetch after some 
parsing/transforming, and since you cannot use Cinlcude for it, you have to 
somehow generate it in the transformer. 

Things which perhaps could help you out:

1) Can you try instead of 
>     WfsXMLPipe n = new WfsXMLPipe(contentHandler);
>       InputSource i = new InputSource(new
>       InputStreamReader(WfsResponse));
>                          getLogger().debug("got the input source");
>                          SAXParser respParser =
>                       (SAXParser)manager.lookup(SAXParser.ROLE);
>                          try
>                          {
>                                  respParser.parse(i,n);
>                          }
>                          finally
>                          {

if it is possible in the transformer to use SourceUtil like: 
 
SourceUtil.toSAX(i, n);

I have experienced very strange non-xml the way you are using it now (xml with 
empty elements, while the inputSource is fine xml and other strange behavior.) 
This was all solved by using the SourceUtil.toSax

Perhaps somebody else can eplain why it is, because I still don't know what is 
wrong with the way above.

2) Perhaps trivial, this one, but the remote stuff you fetch is of course valid 
xml....
3) Since you are probably patching this xml block in xml you already had, 
remember that you really have to take care in your contentHandler the fact that 
you must cut off the document element of the xml you fetched, otherwise you 
will end up havind multiple document elements -> xml not valid.

I will send you in the next mail the code you can probably use directly that 
should work,

Let me know if it solves your stuff,

Regards AS


> 
> 
> I try to create a transformer that send a POST request to a 
> server, grab the
> result and send it down the pipe.  I cannot use CInclude for 
> a variety of
> reason it's not necessary to expose here. 
> 
> For sanity check I create a small console application that 
> send a POST query
> and write it back.
> 
> public class ConsoleTest {
> 
>       /**
>        * @param args
>        */
>       public static void main(String[] args) {
>               // try to get a darn response for MapServer
>               try
>               {
>               URL imsUrl = new
> URL("http://my.wfsserver.gc.ca/WebScripts/mapserv.exe?map=c:\\
> ngwd\\map\\bed
> rock\\bedrock.map&service=WFS&version=1.0.0");
>               HttpURLConnection connection =
> (HttpURLConnection)imsUrl.openConnection();
>               connection.setRequestMethod("POST");
>       
> connection.setRequestProperty("Content-Type","application/xml");
>               connection.setDoOutput(true);
>               connection.setDoInput(true);
>               
>               // get the incoming xml document
>               PrintStream ps = new PrintStream(
> connection.getOutputStream() );
>               // send it to connection
>               ps.print("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
>               ps.print("<wfs:GetFeature
> xmlns:wfs=\"http://www.opengis.net/wfs\";
> xmlns:gml=\"http://www.opengis.net/gml\"; 
> xmlns:ogc=\"www.opengis.net/ogc\"
> xmlns:lcnp=\"http://www.cgcq.rncan.gc.ca/lcnp\"; version=\"1.0.0\"
> service=\"WFS\" maxFeatures=\"100\" outputFormat=\"GML2\">");
>               ps.print("<wfs:Query typeName=\"bedrock\">");
>               ps.print("</wfs:Query>");
>               ps.print("</wfs:GetFeature>");
>               ps.flush();
>               ps.close();
>               System.out.print("Send query");
>               // get the response
>               InputStream response = connection.getInputStream();
>               //               debug info 
>               System.out.print("Response
> message:"+((HttpURLConnection)connection).getResponseMessage()+"\n");
>               System.out.print("Response
> method:"+((HttpURLConnection)connection).getRequestMethod()+"\n");
>               System.out.print("Response
> code:"+String.valueOf(((HttpURLConnection)connection).getRespo
> nseCode())+"\n
> ");
>               System.out.print("content
> length:"+String.valueOf(connection.getContentLength())+"\n");
>               System.out.print("Content type" +
> connection.getContentType()+"\n");
>       
> System.out.print("-----------------------------------------\n");
>                int c = 0;
>          StringBuffer sb = new StringBuffer();
>          while ( (c = response.read()) >= 0 ) {
>              sb.append( (char)c );
>          }
>          System.out.print("my God, it works');
>          System.out.print(sb.toString());
>          response.close();
>          
>               // debug info
>               }
>               catch (Exception e)
>               {
>               System.out.print(e.getMessage());
>               }
>               
> 
>       }
> 
> }
> 
> This works fine.  Now I want to implement the same thing in a 
> transformer
> and stream the result to the next component.
> 
> but when I try to use this in the context of a component, the 
> sax events
> stops before getting to the end
> The HttpUrlConnection portion is identical to the console 
> app. it works, for
> the rest, this is my code
> 
>               WfsXMLPipe n = new WfsXMLPipe(contentHandler);
>                          // this is where I catch the inputstream..
> WfsResponse is 
>                          // the InputStream : 
>                          // WfsResponse = connection.getInputStream();
>                          InputSource i = new InputSource(new
> InputStreamReader(WfsResponse));
>                          getLogger().debug("got the input source");
>                          SAXParser respParser =
> (SAXParser)manager.lookup(SAXParser.ROLE);
>                          try
>                          {
>                                  respParser.parse(i,n);
>                          }
>                          finally
>                          {
>       
>                                  
> manager.release((Component)respParser);
>                                  WfsResponse.close();
>                          }
>                          
>   I loggued the event going through WfsXMLPipe and the 
> complete file is
> indeed received and sent and processed by the SAXParser.
>   the problem is not all the document makes it to the next 
> component (in my
> test case, a serializer), the end of the document is missing, 
> and for small
> documents, I get absolutly nothing.  
> 
> So, the whole document is received, and seems to be processed by the
> SAXParser (by monitoring the WfsXMLPipe, which is an 
> EmbeddedXMLPipe), but
> it does not reappear at the end of the pipe.
>   
>   Any idea ?
>   
>   oh. Cocoon 2.1.6, on a WinXP box.
> 
> Cheers and thanks
> 
> ================================================================
> Eric Boisvert
> Spécialiste TI-GI / IT-IM specialist
> [EMAIL PROTECTED], 418-654-3705, facsimile/télécopieur 
> 418-654-2615
> 490, rue de la Couronne, Québec (Québec), G1K 9A9
> 490, rue de la Couronne, Quebec, Quebec, G1K 9A9
> 
> Laboratoire de cartographie numérique et de photogrammétrie (LCNP)
> Digital Cartography and Photogrammetry Laboratory (DCPL)
> Commission géologique du Canada (Québec) / Geological Survey of Canada
> (Quebec)
> Ressources naturelles Canada / Natural Resources Canada
> Gouvernement du Canada / Government of Canada
> http://www.cgcq.rncan.gc.ca/lcnp
> http://www.nrcan.gc.ca/gsc
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]