PDA

View Full Version : Problem Xqueries within a Qt program. (the Xquery work in BaseX)



Zander87
31st August 2012, 11:57
hi there,
I have problem when querying a .xspf playlist in a Qt programm with Xqueries

What i want is get locations of all files listed in an xspf playlist

What i do is the following xquery:



for $x in doc("/home/max/tmp/test.xspf")/playlist/trackList/track
return data($x/location)

I test this xquery with BaseX and it works


in the Qt programm


QXmlQuery query(QXmlQuery::XQuery10);
QStringList list_of_locations("");
qDebug()<<"is playlist file open?"<<PLAYLIST_FILE->isOpen();
query.setQuery(*XSPF_QUERY_ALL_TRACK);
query.bindVariable("inputDocument", PLAYLIST_FILE); //this affect PLAYLIST_FILE the variable name "inputDocument" inside the Xquery
qDebug()<<"The xquery track is"<<*XSPF_QUERY_ALL_TRACK;
if (query.isValid()){
qDebug()<<"The xquery is valid";

if (!query.evaluateTo(&list_of_locations)){
qDebug()<<"The xquery is evaluated as false (problems occured when querying the playlist)";
qDebug()<<"List of locations"<<list_of_locations;
return false;
}
}

XSPF_QUERY_ALL_TRACK is of type QString*
PLAYLIST_FILE os of type QFile*
output is


is playlist file open? true
The xquery track is "for $x in doc("/home/max/tmp/test.xspf")/playlist/trackList/track
return data($x/location)
"
The xquery is valid
The xquery is evaluated as false (problems occured when querying the playlist)
List of locations ("")
enter define new path

Finally the test.xspf file looks like that


<?xml version="1.0" encoding="UTF-8"?>
<playlist>
<trackList>
<track>
<location>../Music/Autre/Enrique_Iglesias/Enrique_Iglesias_-_Tonight_%28I%27m_F__kin_You%29_%5Bfeat_Ludacris_a nd_DJ_Frank_E%5D.mp3</location>
<identifier>amarok-sqltrackuid://7f0b933f9d18196eb4a3548c94c3a512</identifier>
<title>Tonight (I'm F**kin' You) feat Ludacris and DJ Frank E</title>
<creator>Enrique Iglesias</creator>
<album>Tonight [feat Ludacris &amp; DJ Frank E] - Single</album>
<trackNum>1</trackNum>
<duration>231000</duration>
</track>
</trackList>
<extension application="http://amarok.kde.org">
<queue/>
</extension>
</playlist>

anyone anything?

Best regards ;)