Gianugo Rabellino wrote:

I made some changes to the
DirectoryGenerator (1)
and HTMLGenerator (4)
and introduced a PipelineDirectoryGenerator(2)
and FileInfoGenerator (3) for convenience.

my aim was to scan a directory for (Html,XML-)articles,
extract the titles from the files and show a overview site to the user.


Thaks for your willingness to share! What is the difference between your implementation and the XPath(Directory|Traversable)Generator?

Difference DirectoryGenerator and my impelmentation:


assume the directory-structure to scan is:
<ROOTDIR>
    htmldir
        hallo.html
    emptydir
    nomatchingdir
        hallo.txt


the generator <map:generate type="directory" src="<ROOTDIR>"> <map:parameter name="depth" value="3" /> <map:parameter name="include" value="\.(xml|html)$" /> </map:generate>

produces this:
<dir:directory name="<ROOTDIR>" .../>

ups!
because, the include-pattern is also applied to directories.


the extended directory generator with otpional parameter recurseUnmatchingDirectories="true"

<map:generate type="directory-extended" src="<ROOTDIR>">
        <map:parameter name="depth" value="3" />
        <map:parameter name="include" value="\.(xml|html)$" />
        <map:parameter name="recurseUnmatchingDirectories" value="true" />
</map:generate>

gives You this:
<dir:directory name="<ROOTDIR>" ... >
        <dir:directory name="htmldir" ... >
                <dir:file name="hallo.html" ... />
        </dir:directory>
        <dir:directory name="emptydir" ...>
        </dir:directory>
        <dir:directory name="nomatchingdir" ...>
        </dir:directory>
</dir:directory>


and with parameter excludeEmptyDirectorys="true" this: <dir:directory name="<ROOTDIR>" ... > <dir:directory name="htmldir" ... > <dir:file name="hallo.html" ... /> </dir:directory> </dir:directory>

========================
the difference between the PipelineDirectoryGenerator and
the XPathDirectoryGenerator:

the XPathDirectoryGenerator reads a xml-file, applies a XPath-query and
adds the result as content to the <dir:file>-tag.

if the PipelineDirectoryGenerator finds a matching file (f.e. path/hello.xml)
it tries to get content from a matching pipeline (in the example: 
"cocoon:/content-pipeline/path/hello.xml")
and adds the result as content to the <dir:file>-tag.

example:
<map:pipeline>
        <map:generate type="pipeline-directory" src=".">
                <map:parameter name="extendedFeaturesAsDefault" value="true" />
                <map:parameter name="include" value="\.(xml|html|jpg|gif|png)$" />
                <map:parameter name="contentPipeline" value="cocoon:/content-pipeline" 
/>
        </map:generate>
</map:pipeline>


<map:pipeline internal-only="true"> <map:match pattern="content-pipeline**"> <map:match pattern="content-pipeline/**.xml"> <map:generate src="{1}.xml"/> <map:transform src="dirscan/xsl/dirscanExtractTitles.xsl"/> <map:serialize type="xml"/> </map:match> <map:match pattern="content-pipeline/**.html"> <map:generate type="html" src="{1}.html"/> <map:transform src="dirscan/xsl/dirscanExtractTitles.xsl"/> <map:serialize type="xml"/> </map:match> <map:match pattern="content-pipeline/**"> <map:generate type="fileinfo" src="{1}"/> <map:serialize type="xml"/> </map:match> </map:match> </map:pipeline>

========================================

best regards,
alfred






Reply via email to