Hi Soumanjoy
You are quite right about the nonsensical quality of the translations - I'm
afraid it was just autogenerated data
- I suppose I should have made it more meaningful :).
Thanks a lot for the help. I'll ty the different paths out today.
By the way if I have the following
<keyword>
<originalPhrase src-lang="en">not</originalPhrase>
<trans-equiv src-lang="fr">ne</trans-equiv>
<trans-equiv src-lang="fr">rien</trans-equiv>
<trans-equiv src-lang="fr">plus</trans-equiv>
<trans-equiv src-lang="de">nicht</trans-equiv>
<trans-equiv src-lang="de">kein</trans-equiv>
</keyword>
Is there a way to get the keyword node plus the two translated nodes in one
step -
At the moment I use 2 paths
//originalPhrase[@src-lang=$lang]
to load all the original Phrases
and then for each of these
//originalPhrase[@src-lang=$lang]
to load all the siblings in the correct language - using a
SimpleVariableContext to bind the XPath values
I'd like a list of original phrase - translations - original phrase -
translations.
Like this
<originalPhrase src-lang="en">not</originalPhrase>
<trans-equiv src-lang="de">nicht</trans-equiv>
<trans-equiv src-lang="de">kein</trans-equiv>
Thanks
Nick
-----Original Message-----
From: Soumanjoy Das [mailto:[EMAIL PROTECTED]]
Sent: 13 May 2002 05:42
To: 'Nicholas Sanderson'
Subject: RE: [dom4j-user] XPath Syntax
Hi Nicholas,
Contd:
In your previous XML, I really don't see what 'chat' and 'chaud' have to do
with 'not'. I would expect something like:
<keyword>
<originalPhrase src-lang="en">not</originalPhrase>
<trans-equiv src-lang="fr">ne</trans-equiv>
<trans-equiv src-lang="fr">rien</trans-equiv>
<trans-equiv src-lang="fr">plus</trans-equiv>
<trans-equiv src-lang="fr">jamais</trans-equiv>
<trans-equiv src-lang="fr">point</trans-equiv>
<trans-equiv src-lang="fr">aucun</trans-equiv>
<trans-equiv src-lang="fr">nul</trans-equiv>
<trans-equiv src-lang="fr">personne</trans-equiv>
</keyword>
(All the negatives in French). Anyway, your final successful XPath
//keyword[originalPhrase[@src-lang='en' and
text()='not']]/trans-equiv[@src-lang='fr']/text()
or the one that I wrote:
//originalPhrase[@src-lang='en' and
text()='not']/../trans-equiv[@src-lang='fr']/text()
will actually return you ONLY the text of the immediately following sibling
of the <originalPhrase> node. If you need ALL the corresponding (related)
nodes for the originalPhrase (in your example, all the French equivalents of
the English 'not'), then you should use the XPath
//keyword[originalPhrase[@src-lang='en' and
text()='not']]/trans-equiv[@src-lang='fr']
or
//originalPhrase[@src-lang='en' and
text()='not']/../trans-equiv[@src-lang='fr']
to retrieve a node-SET and iterate through them to get the text of each of
the nodes.
However, I am just surmising upon the usage of your XML, and I am likely off
the mark as to your actual requirement. Anyway, I hope the solution works.
Soumanjoy
-----Original Message-----
From: Nicholas Sanderson [mailto:[EMAIL PROTECTED]]
Sent: Monday, May 13, 2002 1:55 AM
To: [EMAIL PROTECTED]
Subject: [dom4j-user] XPath Syntax
Hi
I've got a document that contains translated phrases
<?xml version="1.0" encoding="UTF-8"?>
<TranslationVerification>
<keyword>
<originalPhrase src-lang="en">never</originalPhrase>
<trans-equiv src-lang="fr">ne</trans-equiv>
<trans-equiv src-lang="fr">rien</trans-equiv>
<trans-equiv src-lang="fr">chat</trans-equiv>
<trans-equiv src-lang="fr">chaud</trans-equiv>
</keyword>
<keyword>
<originalPhrase src-lang="en">not</originalPhrase>
<trans-equiv src-lang="fr">ne</trans-equiv>
<trans-equiv src-lang="fr">rien</trans-equiv>
<trans-equiv src-lang="fr">chat</trans-equiv>
<trans-equiv src-lang="fr">chaud</trans-equiv>
</keyword>
</TranslationVerification>
(The data is obviously nonsense)
I want to find all the phrases in french that match the english word not
(Imagine that this dictionary contains other languages as well
eg <trans-equiv src-lang="ger">nicht</trans-equiv>
The XPath pattern that should get me all the text nodes for an
english -french translation of
'not' should be (I think) //originalPhrase[@src-lang='en and
text()='not']/trans-equiv[@src-lang="fr"]/text()
If I run this query on the document above I get nothing back from
selectNodes()
If I run //originalPhrase[@src-lang='en and text()='not']/text()
I get what I expect - the english not node.
If I add /* - //originalPhrase[@src-lang='en and text()='not']/*
I get nothing at all even though there are clearly nodes below this
position.
Is there a mistake in my syntax or does Jaxen not support XPath quite as I
expect it to?
Thanks
Nick
_______________________________________________________________
Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user
_______________________________________________________________
Have big pipes? SourceForge.net is looking for download mirrors. We supply
the hardware. You get the recognition. Email Us: [EMAIL PROTECTED]
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user