Problem trying to get data out of Tamino

Hello,

I am using the following program to get data out from Tamino. I have a couple of records in Tamino. I am searching for each record with its name. The problem is that even though the structure of the data is the same in the DB, when I go through each node to get the data, for two different recors i am getting 2 different results. How can this happen???

Please find my code below
public ArrayList getDetails(String query, String collection)
{
//String error = “No”;
ArrayList list = new ArrayList();

String title = “”;
String brief = “”;
String body = “”;
String url = “”;
String postcode = “”;
String expiry_date = “”;
String date = “”;
String display = “”;
//list.add(error);

try
{
TaminoClient tamino = new TaminoClient(“http://hqw2kdb1:8060/tamino/ContentDB/” + “/” + collection);
tamino.setSAXimplementer(“com.jclark.xml.sax.Driver”);
tamino.startSession();
TaminoResult tr = tamino.query(query);

while (tr.hasMoreElements())
{
Element myElement = tr.getNextElement();
NodeList myNodeList = myElement.getElementsByTagName(“GEN-INFO”);
if(myNodeList.getLength() <= 0)
{

}
else
{
for (int i = 0; i<=myNodeList.getLength();i++)
{
Node myNode = myNodeList.item(0);

NodeList myNodeList2 = myNode.getChildNodes();
Collection c = getList(myNodeList2);
list.addAll(0, c);
}
}
}
tamino.endSession();
}
catch (TaminoError e)
{
//error = e.toString();
}
catch (Exception e)
{
//error = e.toString();
}

//list.set(0,(Object)error);
return list;
}


public Collection getList(NodeList myNodeList2)
{
ArrayList list = new ArrayList();
Node myNode1;
for(int j=0; j<myNodeList2.getLength(); j++)
{
myNode1 = myNodeList2.item(j);
if(myNode1.getFirstChild() != null)
{
list.add(myNode1.getNodeName());
}
else
{
list.add(“”);
}
}
return list;
}

My XML looks like this


Test
test
Test
Test
Test
Test
Test
Test


The same XML gives 2 results for 2 separate records? I am really confused here.

Can anybody please help??

Thank You

Hello,
Can you please tell us a bit more about your problem. You say that “the same XML gives 2 results for 2 separate records”, but you have only given us one xml instance. Can you please send both instances and give us a more clear idea what the problem is?
Thanks in advance.

Hello,

The second XML (which is another record in Tamino) has the same structure as the first one.


Test1
test1
Test1
Test1
Test1
Test1
Test1
Test1


This problem is really strange. To study the problem in detail, I wrote a program which would go through all the nodes.
I did
NodeList myNodeList = myNode.getChildNodes(); for GEN-INFO.
Then I did
Node myNode = myNodeList.item(0);
String NAME = myNode.getNodeName();

The value of NAME for both the XML’s were different.
The first one gave NAME = #text
The second one gave NAME = DISTRICT-NAME

Then I wrote a program which would go throuh all the child nodes and print out the Node Names.

Results given by the first XML:

#text
DISTRICT-NAME
#text
ABOUT-BRIEF
#text
ABOUT-DISTRICT
#text
DISTRICT-PHOTO
#text
PHOTO-ALT-TAG
#text
ICON
#text
TITLE-IMAGE-LEFT
#text
TITLE-IMAGE-RIGHT

Results given by the second XML:

DISTRICT-NAME
ABOUT-BRIEF
ABOUT-DISTRICT
DISTRICT-PHOTO
PHOTO-ALT-TAG
ICON
TITLE-IMAGE-LEFT
TITLE-IMAGE-RIGHT

This was really strange because I have about 30 records in Tamino database with the same XML structure and only one of them had a different structure. All of them were created in the same method. Finally I had to delete that record and create a new one to solve the problem because the data is on a live database.

Any idea what the problem might be?

Thank you

It looks as if the second instance had no text content in the elements (eg
or
Is this possible?

No, both of the XML’s has text contents in all the nodes.

Another interesting thing is that if i go through all the chile nodes and do
if(myNode1.getFirstChild() != null)
{
list.add(myNode1.getFirstChild().getNodeValue());
}
else
{
list.add(“”);
}

For the first one even if there is data, in the XML, it does not get retriened for some reason but the second XML’s data is retrieved properly.

Can you please zip up your schema and your two complete xml instances and attach them to your next post? Also, what query are you using please?