You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Bastien saquet <ba...@gmail.com> on 2007/11/19 16:33:08 UTC

read several source files from a directory

Hi all,

I have a problem to read information from several xml files all stored
in the same directory.

Basically I need to read in each files (the files are all stored in
./xml directory):
<item>
  <element1>...</element1>
  <element2>...</element2>
</item>

Then I want to use these information in my xsl file. But I find no
solutions to do that.

I tried to used the file generator but I'm a bit confused with it.

Does someone know how could I do that?

Thanks a lot for your help.

Cheers,

Bastien.

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


Re: read several source files from a directory

Posted by Francesco Chicchiriccò <fr...@eposse.it>.
Hi Bastien,
first of all, please take care of quoting (see [1]).

You'll find my answers embedded below.

Cheers.

Bastien saquet wrote:

> Sounds good, but..., I'm not able to use it.
>
> In my sitemap I have:
>
> <map:generate type="xpathdirectory" src="xml">
> 	<map:parameter name="xpath" value="item"/>
> 	<map:parameter name="xmlFiles" value=""/>
> </map:generate>

Uhm, that lonely "item" seems to be quite strange: it should be an  
XPath absolute expression, related to your documents DTD or XSD.

> Then I want to retrieve the value of the element1.
>
> Therefore I wrote in my xsl:
>
> <xsl:for-each select="dir:directory/dir:file/dir:xpath">
> 	<xsl:variable name="element1" select="element1"/>
>         <xsl:value-of select="$element1"/>
> </xsl:for-each>
>
> And, I get nothing... What am I doing wrong?

As a first step, try to put a <map:serialize type="xml"/> just after  
the <map:generate/> you reported above and see if the result is what  
you expected. If not, consider something wrong in generator's  
configuration (probably the xpath, as I said previously).

[1] http://www.netmeister.org/news/learn2quote.html


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


Re: read several source files from a directory

Posted by Bastien saquet <ba...@gmail.com>.
Sounds good, but..., I'm not able to use it.

In my sitemap I have:

<map:generate type="xpathdirectory" src="xml">
	<map:parameter name="xpath" value="item"/>
	<map:parameter name="xmlFiles" value=""/>
</map:generate>

Then I want to retrieve the value of the element1.

Therefore I wrote in my xsl:

<xsl:for-each select="dir:directory/dir:file/dir:xpath">
	<xsl:variable name="element1" select="element1"/>
        <xsl:value-of select="$element1"/>
</xsl:for-each>

And, I get nothing... What am I doing wrong?

Cheers,
Bastien

On Nov 19, 2007 4:48 PM, Francesco Chicchiriccò
<fr...@eposse.it> wrote:
>
> Bastien saquet wrote:
>
> > Hi all,
> >
> > I have a problem to read information from several xml files all stored
> > in the same directory.
> >
> > Basically I need to read in each files (the files are all stored in
> > ./xml directory):
> > <item>
> >   <element1>...</element1>
> >   <element2>...</element2>
> > </item>
> >
> > Then I want to use these information in my xsl file. But I find no
> > solutions to do that.
> >
> > I tried to used the file generator but I'm a bit confused with it.
> >
> > Does someone know how could I do that?
>
> Try [1] or better [2].
>
> Cheers.
>
> [1] http://cocoon.apache.org/2.1/userdocs/directory-generator.html
> [2] http://cocoon.apache.org/2.1/userdocs/xpathdirectory-generator.html
>
>
> ---------------------------------------------------------------------
> 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


Re: read several source files from a directory

Posted by Francesco Chicchiriccò <fr...@eposse.it>.
Bastien saquet wrote:

> Hi all,
>
> I have a problem to read information from several xml files all stored
> in the same directory.
>
> Basically I need to read in each files (the files are all stored in
> ./xml directory):
> <item>
>   <element1>...</element1>
>   <element2>...</element2>
> </item>
>
> Then I want to use these information in my xsl file. But I find no
> solutions to do that.
>
> I tried to used the file generator but I'm a bit confused with it.
>
> Does someone know how could I do that?

Try [1] or better [2].

Cheers.

[1] http://cocoon.apache.org/2.1/userdocs/directory-generator.html
[2] http://cocoon.apache.org/2.1/userdocs/xpathdirectory-generator.html


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