You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Garvin Riensche <g....@gmx.net> on 2004/03/26 12:11:14 UTC
JPath Problem
Hi there,
I have a problem with a JPath expression that schould iterate over some
elements of DOM tree. It should be very easy but for some reason it is
not working. The XML data looks like the following:
<site>
<directory title="...">
<file>...</file>
<file>...</file>
<metadata>
<raw-images>
<image file="...">
<raw>
<tag dir="Exif" name="Make">SONY</tag>
<tag dir="Exif" name="Date/Time">13.12.2003</tag>
...
</raw>
</image>
<image file="...">
<raw>
<tag dir="Exif" name="Make">CANON</tag>
<tag dir="Exif" name="Date/Time">15.11.2001</tag>
...
</raw>
</image>
</raw-images>
</metadaten>
</directory>
What i want to do is just to save the "make" of the images to a
variable and then write it to my database with esql.
My jpath expression looks like the following:
<jpath:for-each select="site/directory/metada/raw-images/image">
<xsp:logic>make=(String)<jpath:value-of
select="./raw/tag[@name='Make']"/>;</xsp:logic>
</jpath>
But i always get an 'No value for xpath: ./raw/tag[@name='Make']'
What is so strange about this is that the path should be correct because
if i am using the <jpath:value-of select> outside the for-each loop with
an absolute url:
<xsp:logic>make=(String)<jpath:value-of
select="site/directory/metadata/raw-images/image/raw/tag[@name='Make']"/>;</xsp:logic>
i can access the "Make".
Maybe it is just a stupid mistake but i just don't know what's wrong. I
am thankfull for any hints!
regards,
Garvin
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Accessing DOM tree (was Re: JPath Problem)
Posted by Garvin Riensche <g....@gmx.net>.
Hi there,
> I have a problem with a JPath expression that schould iterate over some
> elements of DOM tree. It should be very easy but for some reason it is
> not working. The XML data looks like the following:
[....]
Unfortunately I could not figure out what is wrong. As I am quite in a hurry
I have to think about other possibilities of accessing the dom tree. By the
way,
the DOM tree was created with flowscript. I have a pipeline called "data"
which
produces the xml data for the dom tree and in the flowscript I have the
following
to build the dom tree:
var source = resolver.resolveURI("cocoon:/data");
var dom =
Packages.org.apache.cocoon.components.source.SourceUtil.toDOM(source);
As I described before the access with jpath works fine as long as I am not
using
a for-each loop. But as soon as I am using a "jpath:for-each" I can't use
"jpath:value-of select" in the loop because I always get a "xpath not
found".
Are there any other possibilities to access the DOM tree with a loop in an
XSP File
besides JPath?
regards,
Garvin
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: JPath Problem
Posted by Garvin Riensche <g....@gmx.net>.
Hello,
> when looking at your for-each I notice that your xpath isn't correct.
> It says 'directory/metada/raw-images/ ' instead of 'metadata'
> Could this be your problem then?
Ups, sorry - translating mistake ;) it is correct in the xsp.
> Everything else looks fine.
but though isn't working .. ;(
i should have added that i am using cocoon 2.1.2 on windows xp.
regards,
Garvin
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: JPath Problem
Posted by Jeroen Reijn <jr...@hippo.nl>.
Hi,
when looking at your for-each I notice that your xpath isn't correct. It
says 'directory/metada/raw-images/ ' instead of 'metadata'
Could this be your problem then?
Everything else looks fine.
Greetz,
Jeroen
Garvin Riensche wrote:
> Hi there,
>
> I have a problem with a JPath expression that schould iterate over
> some elements of DOM tree. It should be very easy but for some reason
> it is not working. The XML data looks like the following:
>
> <site>
> <directory title="...">
> <file>...</file>
> <file>...</file>
> <metadata>
> <raw-images>
> <image file="...">
> <raw>
> <tag dir="Exif" name="Make">SONY</tag>
> <tag dir="Exif" name="Date/Time">13.12.2003</tag>
> ...
> </raw>
> </image>
> <image file="...">
> <raw>
> <tag dir="Exif" name="Make">CANON</tag>
> <tag dir="Exif" name="Date/Time">15.11.2001</tag>
> ...
> </raw>
> </image>
> </raw-images>
> </metadaten>
> </directory>
>
> What i want to do is just to save the "make" of the images to a
> variable and then write it to my database with esql.
>
> My jpath expression looks like the following:
>
> <jpath:for-each select="site/directory/metada/raw-images/image">
> <xsp:logic>make=(String)<jpath:value-of
> select="./raw/tag[@name='Make']"/>;</xsp:logic>
> </jpath>
>
> But i always get an 'No value for xpath: ./raw/tag[@name='Make']'
>
> What is so strange about this is that the path should be correct
> because if i am using the <jpath:value-of select> outside the for-each
> loop with an absolute url:
>
> <xsp:logic>make=(String)<jpath:value-of
> select="site/directory/metadata/raw-images/image/raw/tag[@name='Make']"/>;</xsp:logic>
>
>
> i can access the "Make".
>
> Maybe it is just a stupid mistake but i just don't know what's wrong.
> I am thankfull for any hints!
>
> regards,
> Garvin
>
>
>
>
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
--
------------------------------------------------------
Hippo Webworks
Grasweg 35
1031 HW Amsterdam
The Netherlands
Tel: 0031-(0)20-6345173
Fax: 0031-(0)20-6345179
http://www.hippo.nl
------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org