You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by "Joe D. Williams" <jo...@mindspring.com> on 2004/02/29 15:00:51 UTC

Best way to use content from one file in another?

I would like a menu that displays links to all files within a given
directory. The director generator can do this, but I would like to use each
file's "title" element rather than the file's "filename" attribute.

CInclude? XInclude?

I can use the document() function in an XSL to do this, but that seems
inefficient.

Suggestions?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Best way to use content from one file in another?

Posted by Jan Hoskens <jh...@schaubroeck.be>.
----- Original Message ----- 
From: "Askild Aaberg Olsen" <as...@xangeli.com>
To: <us...@cocoon.apache.org>
Sent: Sunday, February 29, 2004 3:20 PM
Subject: Re: Best way to use content from one file in another?


> Joe D. Williams wrote:
> > I would like a menu that displays links to all files within a
> > given directory. The director generator can do this, but I
> > would like to use each file's "title" element rather than the
> > file's "filename" attribute.
> >
> > CInclude? XInclude?
> >
> > I can use the document() function in an XSL to do this, but
> > that seems inefficient.
> >
> > Suggestions?
>
> CInclude or Xinclude are the best choices here. There seems to be a
> caching-issue with using the document()-function.
>
> I havent noticed any performance issues between Cinclude and Xinclude, but
> Xinclude implements a standard, and also supports the Xpointer
> specification, allowing you to specify directly the title-element of the
> included file.
>
> There is also an XPathDirectoryGenerator, allowing you to peek into the
> files at generator-level, but I haven't looked at it yet.
>
> Askild
> -

You're right, you can use the xpathdirectorygenerator. My first attempt to
do something alike (listing files and describe it by some element in that
file) was also the cinclude transformer:

    <map:generate type="directory" src="data/{1}">
         <map:parameter name="depth" value="1"/>
    </map:generate>    // this gives me just the dir:file/dir:directory like
below, without the description/xpath
    <map:transform src="set_the_includes.xsl"/>
    <map:transform type="cinclude"/>
    // then style it to create links with description

afterwards I replaced it with this (shorter way):

    <map:generate type="xpathdirectory" src="data/{1}">
         <map:parameter name="xpath" value="/description"/>
         <map:parameter name="xmlFiles" value="\.x.*$"/>
    </map:generate>
    // then style it to create links with description

 This gives me:
<dir:file name="article2.xml" lastModified="1057183738609" date="03.07.03
00:08" size="234">
    <dir:xpath query="/description">
      <description>My second article!</description>
    </dir:xpath>
  </dir:file>Just look into the userdocs that come with the cocoon, under
generators its all there!Kind regards,Jan


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Best way to use content from one file in another?

Posted by Askild Aaberg Olsen <as...@xangeli.com>.
Joe D. Williams wrote:
> I would like a menu that displays links to all files within a 
> given directory. The director generator can do this, but I 
> would like to use each file's "title" element rather than the 
> file's "filename" attribute.
> 
> CInclude? XInclude?
> 
> I can use the document() function in an XSL to do this, but 
> that seems inefficient.
> 
> Suggestions?

CInclude or Xinclude are the best choices here. There seems to be a
caching-issue with using the document()-function.

I havent noticed any performance issues between Cinclude and Xinclude, but
Xinclude implements a standard, and also supports the Xpointer
specification, allowing you to specify directly the title-element of the
included file.

There is also an XPathDirectoryGenerator, allowing you to peek into the
files at generator-level, but I haven't looked at it yet.

Askild
-


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org