You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Richard Korthuis <R....@telecats.nl> on 2000/11/10 10:36:28 UTC

Fetching variable-names using FP

Hello,

I have a difficult question:
I have a file default.xml containing something like this:
....
<column>
	<name>date</date>
	<size>20</size>
	<type>text</type>
</column>
<column>
	<name>sport</name>
	<size>15</size>
	<type>text</type>
</column>
....
and I have a file register.xml containing something like this:
....
<sql:execute-query>
	<sql:driver>...</sql:driver>
	<sql:dburl>...</sql:dburl>
	<sql:username>...</sql:username>
	<sql:query>insert into rooster (date, sport) values ( 	<!-- 1 -->
		'<request:get-parameter name="date"/>',		<!-- 2 -->
		'<request:get-parameter name="sport"/>')		<!--
3 -->
	</sql:query>
</sql:execute-query>
.....
Now I want to change the lines marked with 1,2 and 3 so that the names of
the variables date and sport are fetched from the file default.xml. I know
this should (somehow) be possible using FP. Can anyone tell me how???? Or if
someone knows another way how I can do this, I would be thankful if he could
tell me.

Regards,

Richard Korthuis


Re: Fetching variable-names using FP

Posted by Konstantin Piroumian <KP...@flagship.ru>.
It's not hard to do.
Read the FP docs and I think you will understand yourself what to do:
http://xml.apache.org/cocoon/fp.html

This is what you have to do:
<!-- declare resource file -->
<fp:resource id="defaults">
   <fp:resource-file>default.xml</fp:resource-file>
   <fp:resource-node>/</fp:resource-node>
</fp:resource>

<!-- get values and place them appropriately -->
...
 <sql:query>insert into rooster
(
    <fp:read select="column[1]/name" from="repository" as="string"/>,
    <fp:read select="column[2]/name" from="repository" as="string"/>
)
values ( <!-- get values from whereever you like --> )
</sql:query>

Regards,
    Konstantin Piroumian.

----- Original Message -----
From: "Richard Korthuis" <R....@telecats.nl>
To: <co...@xml.apache.org>
Sent: 10 ноября 2000 г., пятница 12:36
Subject: Fetching variable-names using FP


> Hello,
>
> I have a difficult question:
> I have a file default.xml containing something like this:
> ....
> <column>
> <name>date</date>
> <size>20</size>
> <type>text</type>
> </column>
> <column>
> <name>sport</name>
> <size>15</size>
> <type>text</type>
> </column>
> ....
> and I have a file register.xml containing something like this:
> ....
> <sql:execute-query>
> <sql:driver>...</sql:driver>
> <sql:dburl>...</sql:dburl>
> <sql:username>...</sql:username>
> <sql:query>insert into rooster (date, sport) values ( <!-- 1 -->
> '<request:get-parameter name="date"/>', <!-- 2 -->
> '<request:get-parameter name="sport"/>') <!--
> 3 -->
> </sql:query>
> </sql:execute-query>
> .....
> Now I want to change the lines marked with 1,2 and 3 so that the names of
> the variables date and sport are fetched from the file default.xml. I know
> this should (somehow) be possible using FP. Can anyone tell me how???? Or
if
> someone knows another way how I can do this, I would be thankful if he
could
> tell me.
>
> Regards,
>
> Richard Korthuis
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: cocoon-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: cocoon-users-help@xml.apache.org
>