Simple XML is not parsed anyway on N950 generating unexpected error in the application
-
Hi to all,
last night I lost a lot of time trying to solve a strange problem parsing a XML file that seems very simple but generates a couple of different error conditions that never met before.
Here is the schema of the file:
@
<?xml version="1.0" encoding="UTF-8"?>
<categories validity="86400">
<category name="name 1 title">Medium quantity text 1. [...] About a page on the device</category>
<category name="name 1 title">Medium quantity text 1. [...] About a page on the device</category>
<category name="name 1 title">Medium quantity text 1. [...] About a page on the device</category>
</categories>
@
I should manage these data outside a standard ListView so I plan to join the elements together using the method XmlListModel.get() as explained in the documentation.
The XmlListModel to parse this file is in the following code snippet:
@
XmlListModel{
id: model
///////// XML Debug /////////////////
function testXML() {
switch(model.status) {
case XmlListModel.Null:
console.log("<<<XML>>> No data set for the model");
break;
case XmlListModel.Loading:
console.log("<<<XML>>> xml always loading");
break;
case XmlListModel.Ready:
console.log("<<<XML>>> xml data ready");
console.log(model.get(0).category_tit);
break;
case XmlListModel.Error:
console.log("<<<XML>>> model error " + model.errorString);
break;
}
}
/////////////////////////////////////// The folder path source: "../../data/download/config/aboutInfo.xml" // The root query query: "/categories" XmlRole { name: "category_tit"; query: "category/@name/string()" } XmlRole { name: "category_desc"; query: "category/string()" } onStatusChanged: { testXML(); }
}
@
This component is the first element created on a page so the loading / parsing process is initiated as the page is loaded.
Starting the application when this page is called from a button after some seconds I see the following output:
@
<<<XML>>> xml always loading
[... some other debug notes unrelated with the poblem ...]
Error XPTY0004 in file:///opt/appName/bin/appName, at line 2, column 63: Required cardinality is zero or one("?"); got cardinality one or more("+").
Error XPTY0004 in file:///opt/appName/bin/appName, at line 2, column 63: Required cardinality is zero or one("?"); got cardinality one or more("+").
<<<XML>>> xml data ready
undefined
@
The test function output means that the process is running correctly and the file is opened: the parser starts loading the file (line 1) then are generated two errors from the binary code and the last status shows that all is done.
(line 6) shows that the test output of a field with the get(0) reports somethings like and empty list as it is I really have.
Randomly the same shows the final result (lines 5 adn 6) reporting an error parsing the file.
I have serached for this cardinality error but I have found only notices related to database problems.
A last note: if I don't open this page the application binary does not generate any kind of errror.Does someone knows what is can be? Any suggestions?
Thank you.
-
A bit late but if you change your query to:
@query: "/categories/category"@And remove "category" from the XmlRole items it should work.
I'm having a similar issue with an XPath query where my XML contains a list of similar nodes (RouteLink) deeper in the tree, and my root query starts from Journey. If RouteLinks contain more than one node, I get the same cardinality error:@<Journeys>
<Journey>
<SequenceNo>0</SequenceNo>
<DepDateTime>2012-07-08T16:50:00</DepDateTime>
<ArrDateTime>2012-07-08T17:16:00</ArrDateTime>
<DepWalkDist>0</DepWalkDist>
<ArrWalkDist>0</ArrWalkDist>
<NoOfChanges>1</NoOfChanges>
<Guaranteed>false</Guaranteed>
<CO2factor>10</CO2factor>
<NoOfZones>5</NoOfZones>
<PriceZoneList>12000240,12000241,12000242,12000243,12000250</PriceZoneList>
<FareType>Normaltaxa</FareType>
<Prices>...</Prices>
<JourneyKey>...</JourneyKey>
<RouteLinks>
<RouteLink>...</RouteLink>
<RouteLink>...</RouteLink>
</RouteLinks>
<Distance>19960</Distance>
<CO2value>0.002259</CO2value>
</Journey>
<Journey>...</Journey>
<Journey>...</Journey>
<Journey>...</Journey>
<Journey>...</Journey>
</Journeys>@