You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Andreas Hartmann <an...@apache.org> on 2004/02/24 10:21:51 UTC

[Flow] Importing multiple scripts? (ScriptDirectoryNode)

Hi Cocoon developers,

is it currently possible to include a set of scripts
dynamically? I imagine something like a
o.a.c.c.treeprocessor.sitemap.ScriptDirectoryNode
that works similar to the DirectoryGenerator by
gathering all .js files in a certain directory tree.

Or is there another way to achieve this functionality?

-- Andreas


Re: [Flow] Importing multiple scripts? (ScriptDirectoryNode)

Posted by Joerg Heinicke <j....@ewerk.com>.
Bertrand Delacretaz <bdelacretaz <at> apache.org> writes:

> 
> Le Mardi, 24 fév 2004, à 13:12 Europe/Zurich, Andreas Hartmann a écrit :
> > ...I would use CInclude. I'll try if it includes text files
> > and complain if it doesn't work :)
> 
> Note that there are at least two ways to "XMLize" text files:

At least the XInclude spec knows an "include text" mode. It seems our our
implementation suports it:

if (parse.equals("text")) {
  getLogger().debug("Parse type is text");
  InputStream input = url.getInputStream();
  Reader reader = new BufferedReader(new InputStreamReader(input));
  int read;
  char ary[] = new char[1024];
  if (reader != null) {
    while ((read = reader.read(ary)) != -1) {
      super.characters(ary,0,read);
    }
    reader.close();
  }
} else if (parse.equals("xml")) {
  ...
}

This would make a text parser superfluous.

And what about CInclude? Does it also know a text mode?

Joerg


Re: [Flow] Importing multiple scripts? (ScriptDirectoryNode)

Posted by Andreas Hartmann <an...@apache.org>.
Bertrand Delacretaz wrote:

> Le Mardi, 24 fév 2004, à 13:12 Europe/Zurich, Andreas Hartmann a écrit :
> 
>> ...I would use CInclude. I'll try if it includes text files
>> and complain if it doesn't work :)
> 
> 
> Note that there are at least two ways to "XMLize" text files:
> 
> -The chaperon block TextGenerator, which puts the whole text in a single 
> element

This one is probably useful for this purpose.
I'll try to use it.

Thanks!
-- Andreas


Re: [Flow] Importing multiple scripts? (ScriptDirectoryNode)

Posted by Joerg Heinicke <j....@ewerk.com>.
Andreas Hartmann <andreas <at> apache.org> writes:

> >>OK. So I have to write scripts included in XML, aggregate
> >>them using the DirectoryGenerator, strip the XML tags and 
> >>serialize as text?
> > 
> > 
> > embedding Javascript in XML is IMHO ugly but it would work this way.
> > Does the directory generator read a all files including their content or
> > do you use the cinclude transformer? If so and it doesn't accept non-xml
> > content it should be patched.
> 
> I would use CInclude. I'll try if it includes text files
> and complain if it doesn't work :)

I'm nearly sure it won't work. The DirectoryGenerator itself does not include
any file, the XPathDirectoryGenerator expects XML files:

source = resolver.resolveURI(xmlFile.toURL().toExternalForm());
this.doc = this.parser.parseDocument(SourceUtil.getInputSource(source));

Joerg


Re: [Flow] Importing multiple scripts? (ScriptDirectoryNode)

Posted by Bertrand Delacretaz <bd...@apache.org>.
Le Mardi, 24 fév 2004, à 13:12 Europe/Zurich, Andreas Hartmann a écrit :
> ...I would use CInclude. I'll try if it includes text files
> and complain if it doesn't work :)

Note that there are at least two ways to "XMLize" text files:

-The chaperon block TextGenerator, which puts the whole text in a 
single element

-The slop block SlopGenerator, which creates one element for each input 
line

-Bertrand


Re: [Flow] Importing multiple scripts? (ScriptDirectoryNode)

Posted by Andreas Hartmann <an...@apache.org>.
Reinhard Poetz wrote:

[...]


>>OK. So I have to write scripts included in XML, aggregate
>>them using the DirectoryGenerator, strip the XML tags and 
>>serialize as text?
> 
> 
> embedding Javascript in XML is IMHO ugly but it would work this way.
> Does the directory generator read a all files including their content or
> do you use the cinclude transformer? If so and it doesn't accept non-xml
> content it should be patched.

I would use CInclude. I'll try if it includes text files
and complain if it doesn't work :)

Thanks again!

-- Andreas


RE: [Flow] Importing multiple scripts? (ScriptDirectoryNode)

Posted by Reinhard Poetz <re...@apache.org>.

> -----Original Message-----
> From: news [mailto:news@sea.gmane.org] On Behalf Of Andreas Hartmann
> Sent: Tuesday, February 24, 2004 11:54 AM
> To: dev@cocoon.apache.org
> Subject: Re: [Flow] Importing multiple scripts? (ScriptDirectoryNode)
> 
> 
> Reinhard Poetz wrote:
> > From: Andreas Hartmann
> > 
> > 
> >>Hi Cocoon developers,
> >>
> >>is it currently possible to include a set of scripts
> >>dynamically? I imagine something like a 
> >>o.a.c.c.treeprocessor.sitemap.ScriptDirectoryNode
> >>that works similar to the DirectoryGenerator by
> >>gathering all .js files in a certain directory tree.
> >>
> >>Or is there another way to achieve this functionality?
> > 
> > 
> > You can dynamically add scripts using
> > 
> >  <map:flow>
> >    <map:script src="cocoon://bla"/>
> >  </map:flow>
> > 
> > So you can use the DirectoryGenerator but be aware of possible 
> > conflicts by using the same function or global variable names.
> 
> OK. So I have to write scripts included in XML, aggregate
> them using the DirectoryGenerator, strip the XML tags and 
> serialize as text?

embedding Javascript in XML is IMHO ugly but it would work this way.
Does the directory generator read a all files including their content or
do you use the cinclude transformer? If so and it doesn't accept non-xml
content it should be patched.

--
Reinhard


> 
> Thank you for the hint,
> -- Andreas
> 


Re: [Flow] Importing multiple scripts? (ScriptDirectoryNode)

Posted by Andreas Hartmann <an...@apache.org>.
Reinhard Poetz wrote:
> From: Andreas Hartmann
> 
> 
>>Hi Cocoon developers,
>>
>>is it currently possible to include a set of scripts 
>>dynamically? I imagine something like a 
>>o.a.c.c.treeprocessor.sitemap.ScriptDirectoryNode
>>that works similar to the DirectoryGenerator by
>>gathering all .js files in a certain directory tree.
>>
>>Or is there another way to achieve this functionality?
> 
> 
> You can dynamically add scripts using
> 
>  <map:flow>
>    <map:script src="cocoon://bla"/>
>  </map:flow>
> 
> So you can use the DirectoryGenerator but be aware of possible conflicts
> by using the same function or global variable names.

OK. So I have to write scripts included in XML, aggregate
them using the DirectoryGenerator, strip the XML tags and
serialize as text?

Thank you for the hint,
-- Andreas


RE: [Flow] Importing multiple scripts? (ScriptDirectoryNode)

Posted by Reinhard Poetz <re...@apache.org>.
From: Andreas Hartmann

> Hi Cocoon developers,
> 
> is it currently possible to include a set of scripts 
> dynamically? I imagine something like a 
> o.a.c.c.treeprocessor.sitemap.ScriptDirectoryNode
> that works similar to the DirectoryGenerator by
> gathering all .js files in a certain directory tree.
> 
> Or is there another way to achieve this functionality?

You can dynamically add scripts using

 <map:flow>
   <map:script src="cocoon://bla"/>
 </map:flow>

So you can use the DirectoryGenerator but be aware of possible conflicts
by using the same function or global variable names.

--
Reinhard