You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Winkler, Steve" <st...@sapmarkets.com> on 2001/03/14 06:10:54 UTC

file trouble?

Hi all,

I'm working on a proof of concept and I have a class that basically collects
XML documents from a directory and puts them together to form a bigger XML
document.  This document is then written to a file in a different directory.
I know that this works fine if I just execute the code in a main method, but
now I want to have it be event driven.  So I changed the name of the main
method to collect and I try to instantiate the object and then call the
method from XSP.  I was thinking that by doing this when someone accessed
the page it would execute the code that collects the documents but it
doesn't appear to work. Any ideas why?
The only thing I can think of is that it doesn't like the way I use the file
paths, but since they're absolute I don't see any problems.

I do something like this in XSP:

doccollector d = new doccollector();
d.collect();  


The collect method looks something like this:
File dir = new File( "C:\\path\\to\\dir\\" );
File[] f = dir.listFiles();

for each file, 
	create an XmlDocument
	copy some nodes 
	create a new XmlDocument with all of the copied nodes.

File f = new File( "c:\\path\\to\\file\\filename.xml" );
FileOutputStream fos = new FileOutputStream( f );
CBL.write( fos );


Thanks for your help,

Steve

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


RE: file trouble?

Posted by Kirk Woerner <ki...@stoneseeker.com>.
Why don't you just use xinclude?
Assuming you can't, in what way "it doesn't work"

> -----Original Message-----
> From: Winkler, Steve [mailto:steve.winkler@sapmarkets.com]
> Sent: Tuesday, March 13, 2001 10:11 PM
> To: 'cocoon-users@xml.apache.org'
> Subject: file trouble?
>
>
>
> Hi all,
>
> I'm working on a proof of concept and I have a class that
> basically collects
> XML documents from a directory and puts them together to form a bigger XML
> document.  This document is then written to a file in a different
> directory.
> I know that this works fine if I just execute the code in a main
> method, but
> now I want to have it be event driven.  So I changed the name of the main
> method to collect and I try to instantiate the object and then call the
> method from XSP.  I was thinking that by doing this when someone accessed
> the page it would execute the code that collects the documents but it
> doesn't appear to work. Any ideas why?
> The only thing I can think of is that it doesn't like the way I
> use the file
> paths, but since they're absolute I don't see any problems.
>
> I do something like this in XSP:
>
> doccollector d = new doccollector();
> d.collect();
>
>
> The collect method looks something like this:
> File dir = new File( "C:\\path\\to\\dir\\" );
> File[] f = dir.listFiles();
>
> for each file,
> 	create an XmlDocument
> 	copy some nodes
> 	create a new XmlDocument with all of the copied nodes.
>
> File f = new File( "c:\\path\\to\\file\\filename.xml" );
> FileOutputStream fos = new FileOutputStream( f );
> CBL.write( fos );
>
>
> Thanks for your help,
>
> Steve
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
>


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>