• Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » cant execute Xpath with name()

#1 2008-11-26 08:37:51

dosy07
Member
Registered: 2008-11-26
Posts: 17

cant execute Xpath with name()

Tags: [context, xml]

Hi,

I want to load xml in contextLoad
tContextLoad needs key and value

My xml is like this :

<config>
  <HOSTNAME>toto</HOSTNAME>
  <DATABASE>titi</DATABASE>
  ...
</config>

i configure my columns like this

loop : "/config/*"

key : "name()"
value : "node()"

but when i execute this, i have exception :
Exception in component tFileInputXML_1
org.dom4j.XPathException: Exception occurred evaluting XPath: The result of the XPath expression is not a Node. It was: HOSTNAME of type: java.lang.String
    at org.dom4j.xpath.DefaultXPath.selectSingleNode(DefaultXPath.java:169)

please help me,
or how to convert this with key and value columns ?

cdt,
arnaud

Offline

#2 2008-11-26 10:58:33

shong
Talend team
Registered: 2007-08-29
Posts: 10289
Website

Re: cant execute Xpath with name()

Hello

or how to convert this with key and value columns ?

Why don't you use a tFileXMLInput to extract data from your xml file?

Best regards

         shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#3 2008-11-26 14:49:41

dosy07
Member
Registered: 2008-11-26
Posts: 17

Re: cant execute Xpath with name()

i already use TXmlFile component but i cant convert name node to column, it generate String exception (see upper)

Offline

#4 2008-11-27 02:53:41

shong
Talend team
Registered: 2007-08-29
Posts: 10289
Website

Re: cant execute Xpath with name()

Hello Dosy07

Please upload some screenshots of your job with detailed information.

Best regards

         shong


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#5 2008-11-27 08:53:24

dosy07
Member
Registered: 2008-11-26
Posts: 17

Re: cant execute Xpath with name()

offcourse,

http://www.postimage.org/gxU_iIJ.jpg

and the exception :
Starting job Chargement_context_config at 08:46 27/11/2008.
Exception in component tFileInputXML_1
org.dom4j.XPathException: Exception occurred evaluting XPath: The result of the XPath expression is not a Node. It was: HOSTNAME of type: java.lang.String
    at org.dom4j.xpath.DefaultXPath.selectSingleNode(DefaultXPath.java:169)
    at reprise_action_nova_20081124.chargement_context_config_0_1.Chargement_context_config.tFileInputXML_1Process(Chargement_context_config.java:458)
    at reprise_action_nova_20081124.chargement_context_config_0_1.Chargement_context_config.runJobInTOS(Chargement_context_config.java:694)
    at reprise_action_nova_20081124.chargement_context_config_0_1.Chargement_context_config.main(Chargement_context_config.java:608)
Job Chargement_context_config ended at 08:46 27/11/2008. [exit code=1]

Offline

#6 2008-11-27 10:20:30

shong
Talend team
Registered: 2007-08-29
Posts: 10289
Website

Re: cant execute Xpath with name()

Hello

"name" ,"node" are not node in your xml file. Your job should be like as the screenshot shows.
please download the user documentation and see the use case.

Best regards,

         shong


Uploaded Images


Email:shong@talend.com
Choose Talend, Enjoy Talend!
New & Event: Talend Help Center
Talend-->the leader of open source data management and application integration solutions!

Offline

#7 2008-11-27 10:59:08

dosy07
Member
Registered: 2008-11-26
Posts: 17

Re: cant execute Xpath with name()

To use a tcontextLoad
i need key and value columns

My xml is like this
<config>
  <mybase>
     <hostname>titi<hostname>
     <database>toto</database>
     <port>10000</port
   
  </mybase>
</config>

i need to this output to use tContextLoad :

key|value
hostname;titi
database;toto
port;10000

then the xpath is
loop : "/config/mybase/*"
key : "name()"
value : "node()"

if i configure this
key : "node()"
value : "node()"

its work :
key|value
titi;titi
toto;toto
10000;10000

but i dont have the name of node for the context name.
if i used name() instead node(), i have exception :

org.dom4j.XPathException :
hostname of type: java.lang.String

If i use your solution, i dont have key/value columns to use it in tcontextLoad

In french :
pour utiliser le tcontextLoad
j'ai besoin de 2 colonnes key/value

mon fichier xml ressemble à ceci (je ne suis pas propriétaire du fichier)
<config>
  <mybase>
     <hostname>titi<hostname>
     <database>toto</database>
     <port>10000</port
      </mybase>
</config>

j'ai besoin en sortie d'un truc qui ressemble à ceci :

key|value
hostname;titi
database;toto
port;10000

donc le xpath devient :
loop : "/config/mybase/*"
key : "name()"
value : "node()"

cela fonctionne avec un outils de requête xpath


Si je configure ceci sous Talend
key : "node()"
value : "node()"

Cela fonctionne :
key|value
titi;titi
toto;toto
10000;10000


mais la fonction name() renvoie une String hors talend a besoin d'un objet Node, d'où l'exception :
org.dom4j.XPathException :
hostname of type: java.lang.String

Je ne sais pas comment contourner ce problème

cdt,
arnaud

Offline

#8 2008-11-27 19:56:54

mhirt
Talend team
Registered: 2006-09-19
Posts: 1633

Re: cant execute Xpath with name()

Hello dosy07,

Can you report a bug on our bugtracker ?

Thx

Offline

  • Index
  •  » Talend Open Studio for Data Integration » Usage, Operation
  •  » cant execute Xpath with name()

Board footer

Powered by FluxBB