Cannot convert XPath value to Java object: required class is org.w3c.dom.NodeList;
Trying to run this XPath
for $index in (1 to count(/root ) )
return
( if (exists ( /root/items[$index]/item[]/sport[1] ) )
then /root/items[$index]/item[]/sport[1]/text()
else
( if (exists ( /root/count[$index] ) )
then concat('Record Count = ' ,//root/count[$index]/text())
else
"N/A "))
or this one
for $index in (1 to count(/root ) )
return
( if (exists ( /root/items[$index]/item[]/sport[1] ) )
then /root/items[$index]/item[]/sport[1]/text()
else
"N/A ")
I am trying to get get the NA or record count when the element is missing. This has worked in the past but for some reason is no longer working.
I have even checked to extract empty/missing values in the options section of the JSON data bank. But it is erroring out and the empty/missing values are not displaying in my data sources. So my data is off because the values go to the next available record
This is the error message that I am receiving
Cannot convert XPath value to Java object: required class is
org.w3c.dom.NodeList; supplied value has type xs:string
Answers
-
What version of SOAtest are you using? Were you using a different version when it was working previously?
0 -
Good Morning,
We are on Version: 9.10.7.20190506
Build id: 2019-05-06-2044. I do not remember if it was a different version but I guess that could be possible.Is there a way to get it to work on this version?
Thanks
0 -
Cannot convert XPath value to Java object: required class is
org.w3c.dom.NodeList; supplied value has type xs:stringEvaluating XPath expressions that return non Node/NodeList values like xs:string was implemented for the SOAtest 9.10.8 release.
We are on Version: 9.10.7.20190506
You need to be using at least SOAtest 9.10.8.
In previous releases you would have to use an XPath expression that returns a node instead a string. So, you can change 'else "N/A"' to something like 'else parse-xml("<foo>N/A</foo>")/foo/text()'.
0 -
Thank you so i tried that
for $index in (1 to count(/root/items[] ) )
return
( if (exists ( /root/items[$index]/item[]/sport[1] ) )
then /root/items[$index]/item[*]/sport[1]/text()
else parse-xml("NO SPORT")/foo/text() )So it will give me NO Sport for the first record and then nothing for the 2nd & 3rd records
DisplayName Type Sport League
The Open competitiongroup NO SPORT NO LEAGUE
MLB The Show competitiongroup
The Masters competitiongroupThen the below data will populate the empty rows and present incorrect data.
DisplayName Type Sport League
The Open competitiongroup NO SPORT NO LEAGUE
MLB The Show competitiongroup soccer concacaf.nations.league
The Masters competitiongroup football college-footballThis is what I would like to see.
DisplayName Type Sport League
The Open competitiongroup NO SPORT NO LEAGUE
MLB The Show competitiongroup NO SPORT NO LEAGUE
The Masters competitiongroup NO SPORT NO LEAGUE
Bahamas @ event soccer concacaf.nations.league
Georgia @ event football college-football
N/A N/A N/A N/AWould like to see the data aligned properly. Not every record has all of the fields. That is where I am having issues.
Thanks
0