You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by John Moylan <jo...@nua-tech.com> on 2002/06/17 14:38:00 UTC

Xinclude + regex (?) AKA How do I include all of the xml files in a directory?

Hi,

I have multiple XML documents in a directory and I need to generate an index for same on the fly. The index would consist of a html file which pulls in a description from each of the XML files in the directory and links the description back to the individual XML files. Is this possible with Xinclude?

Can I use regex with xinclude and loop through the directory contents somehow for *.xml?


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

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


Re: Xinclude + regex (?) AKA How do I include all of the xml files in a directory?

Posted by Bertrand Delacretaz <bd...@codeconsult.ch>.
On Monday 17 June 2002 14:38, John Moylan wrote:
> I have multiple XML documents in a directory and I need to generate an
> index for same on the fly. 
>. . .

One approach is to use the DirectoryGenerator to get the list of files in 
your directory, and manipulate it with an XSLT transform to generate a 
document suitable for XInclude (or CInclude, the Cocoon version, which is 
more flexible AFAIK).

You can then use an aggregate to combine this with your index html file, 
something like (sitemap excerpts):

<!-- use DirectoryGenerator + XSLT to prepare for CInclude -->
<map:match pattern="cinclude-src.xml">
 . . .

<!-- pass cinclude-src.xml through CInclude transformer-->
<map:match pattern="files-list.xml">
  <map:generate src="cocoon:/cinclude-src.xml"/>
  <map:transform type="cinclude"/>
 . . .

<!-- use HTMLGenerator to parse HTML file -->
<map:match pattern="index.xml">
 . . .

<map:match pattern="index.html">
  <!-- put it all together -->
  <map:aggregate element="index">
    <map:part element="files" src="cocoon:/files-list.xml"/>
    <map:part element="index" src="cocoon:/index.xml"/>
  </map:aggregate>
   <!-- apply XSLT, etc. -->
 . . .

Hope this helps!
-- 
 Bertrand Delacrétaz (codeconsult.ch, jfor.org)

 buzzwords: XML, java, XSLT, cocoon, mentoring/teaching/coding.
 disclaimer: eternity is very long. mostly towards the end. get ready.






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

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