cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Derek Hohls" <dho...@csir.co.za>
Subject RE: Directory includes
Date Tue, 28 Jun 2005 08:31:32 GMT
OK - you need a 2-part solution here.

The first is to  get the list of files you want - this can be done via
the match you have suggested:

<map:generate src="my/dir" type="directory" include="*.xml"/> 

The next step is to process those files to get the data you want.  
This can be done via a cinclude.  Before this happens you will need
a stylesheet to transform the generated file list, and set the extraction
parameters for the data you need - here is a relevant sample snippet:

<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:dir="http://apache.org/cocoon/directory/2.0"
  xmlns:ci="http://apache.org/cocoon/include/1.0"
  >

<!-- directories -->
<xsl:template match="dir:directory">
  <root-element>
    <xsl:for-each select="dir:file">
      <file name="{@name}">
        <ci:include src="cocoon:/{@name}"/> <!-- an xpath statement -->
      </file>
    </xsl:for-each>  
  </root-element>  
</xsl:template>

You can then run a cinclude transform - mine looks like:

<map:transform type="cinclude">
  <map:parameter name="expires" value="3600"/>
  <map:parameter name="purge" value="false"/>
  <map:parameter name="parallel" value="true"/>
  <map:parameter name="preemptive" value="true"/>
</map:transform>

But you should read the docs to get the right parameters for 
your setup.

HTH
Derek

>>> Yjanet@dsmdir.cea.fr 2005/06/28 10:10:30 AM >>>
I have a directory which contains many XML files which contain each one
element of the newsboard I want to display. So I need to do something like 
<map:generate type="file" src="/my_directory/*.xml" element="my_element"/>

One told me this would'nt work neither would <map:generate type="directory"
src="/my_directory/"/> which would only returns a file listing. What I need
is the whole content of the files, not only some pieces of information, just
as if I did something like what follows but without specifying any of the
filenames which may evolve from time to time, depending on submissions...
<map:aggregate element="my_element">
 <map:part src="/my_directory/file1.xml"/>
 <map:part src="/my_directory/file2.xml"/>
 ...
 <map:part src="/my_directory/fileN.xml"/>
</map:aggregate>




> You say:
> "I don't think <map:generate type="directory" .../> would be of any use"
> but you have not given any details as to why you think this;
> a sample of what you are trying to achieve might help others
> make some suggestions... why write new code when existing
> code would work for you?

>>> Yjanet@dsmdir.cea.fr 2005/06/28 09:28:54 AM >>>
>> In my deepest fears, I found some kind of a solution: should I have to
>> write some DirectoryAggregateGenerator class in java and include it 
>> into my cocoon libraries to use it or may I do something directly in XML 
>> within the sitemap files ?



---------------------------------------------------------------------
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


Mime
View raw message