{ "id": "61718", "key": "TIMOB-1086", "fields": { "issuetype": { "id": "2", "description": "A new feature of the product, which has yet to be developed.", "name": "New Feature", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "12580", "description": "Dual Runtime 1.8.0", "name": "Release 1.8.0.1", "archived": true, "released": true, "releaseDate": "2011-12-22" } ], "resolution": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2011-12-19T10:19:23.000+0000", "created": "2011-04-15T02:43:42.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "dom", "feature", "ios", "iphone", "xml" ], "versions": [], "issuelinks": [], "assignee": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-24T18:39:12.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "{html}

We have a request to fix our DOM xml functionality. See\r\nthe helpdesk ticket for reference.

\r\n

http://helpdesk.appcelerator.net/tickets/2819

{html}", "attachment": [], "flagged": false, "summary": "XML Parsing", "creator": { "name": "ctredway1", "key": "ctredway1", "displayName": "ctredway", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "rpfeiffer", "key": "rpfeiffer", "displayName": "Ralf Pfeiffer", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "162670", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "body": "h4.Problem\r\nApp stops / crashes at \"semi-random\" points without giving any error-message, after getting the XML object script crawls over the given XML Object and tries to create a real Object. So to speak parsing is returning an empty object and crashes.\r\n\r\nh4.Tested on\r\nSimulator iOS 4.3\r\n\r\nh4.Repro sequence\r\n{code:title=app.js}\r\nfunction xmlNodeList2Array(_$nodeList) {\r\n\tTi.API.info(\"xmlNodeList2Array\");\r\n\tvar $array = Array();\r\n\tvar $nodeListLenght = _$nodeList.getLength();\r\n\r\n\tfor(var i = 0; i < $nodeListLenght; i++) {\r\n\t\tvar $item = _$nodeList.item(i);\r\n\t\tif($item.getNodeType() == 1)\r\n\t\t\t$array.push($item.getText());\r\n\t}\r\n\tTi.API.info(\"----- \" + $array.length);\r\n\treturn $array;\r\n}\r\n\r\nTi.include('ccdsRestHandler.js')\r\n\r\nvar $currentOffset = 0;\r\nvar $limit = 40;\r\n\r\nvar caHandler = new ccdsRestHandler();\r\n\r\ncaHandler.onReady = function($campgrounds) {\r\n\tTi.API.info(\"GOT \" + $campgrounds.length + \" ENTRIES\");\r\n\tif($campgrounds.length > 0) {\r\n\t\tCA.MODEL.Campground.saveCampgroundObjs($campgrounds);\r\n\t}\r\n\r\n\tTitanium.App.fireEvent(\"refreshCampgrounds\");\r\n\r\n}\r\ncaHandler.ccdsQuery(\"CAMPINGPLATZ\", 1, false, $limit);\r\n{code}\r\n\r\n{code:title=ccdsRestHandler}\r\n/*\r\n * ccdsRestHandler\r\n * Build to create a bridge between titanium apps and CCDS-Website which uses ccdsREST\r\n */\r\n\r\n\r\nfunction ccdsRestHandler() \r\n{\r\n\r\n\tthis.rest_url \t= 'http://www.vcwmv.de/ccds_extensions/ccdsModules/ccdsREST/index.php';\r\n\tthis.onReady\t= function(classArray){};\r\n\tthis.onError\t= function(oEvent){ Ti.API.info(oEvent); };\r\n\t\r\n\tthis.ccdsQuery \t= function(ccdsClassName,lang_id,where,limit,offset)\r\n\t{\r\n\t\tTi.API.info(\"ccdsRestHandler ccdsQuery-func \"+ccdsClassName+\",\"+lang_id+\",\"+where+\",\"+limit);\r\n\t\tvar CRH = this; // C R H = ccds rest handler\r\n\t\t\r\n\t\tvar RESTclient = Ti.Network.createHTTPClient();\r\n\t\t\r\n\t\tRESTclient.onerror = function(oEvent)\r\n\t\t{\r\n\t\t\tTi.API.info(oEvent); \r\n\t\t\tTi.API.info(oEvent.source.location);\r\n\t\t};\r\n\t\t\r\n\t\t//RESTclient.setRequestHeader(\"HTTP_ACCEPT\",\"application/jsonrequest\");\r\n\t\tRESTclient.onload = function()\r\n\t\t{\r\n\t\t\tTi.API.info(\"RESTclient.onload loaded\");\r\n\t\t\t//Ti.API.info('ccds xml ' + this.responseXML + ' text ' + this.responseText);\r\n\t\t\tvar doc = this.responseXML.documentElement;\r\n\t\t\tvar elements = doc.getElementsByTagName(ccdsClassName);\r\n\t\t\t\r\n\t\t\tvar objArray = CRH.tiXML2object(elements,true);\r\n\t\t\tTi.API.info(\"RESTclient.onload | Loaded \"+objArray.length+\" Elements\");\r\n\t\t\t\r\n\t\t\tCRH.onReady(objArray);\r\n\t\t\t\r\n\t\t};\r\n\t\r\n\t\t var $rest_url = this.rest_url\r\n\t\t\t\t\t\t\t+\"?action=0\"\r\n\t\t\t\t\t\t\t+\"&ccdsclass=\"+ccdsClassName\r\n\t\t\t\t\t\t\t+\"&lang_id=\"+lang_id;\r\n\t\t\t\t\t\t\t\r\n\t\t$rest_url += (limit)?\"&limit=\"+limit:\"\";\r\n\t\t$rest_url += (offset)?\"&offset=\"+offset:\"\";\r\n\t\t$rest_url += (where)?\"&where=\"+where:\"\";\r\n\t\tTi.API.info(\"$rest_url : \"+$rest_url);\r\n\t\tRESTclient.open(\r\n\t\t\t\t\t\t'GET',\r\n\t\t\t\t\t\t$rest_url\r\n\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\t\r\n\t\tRESTclient.send();\r\n\t\tRESTclient = null;\r\n\t}\r\n\t\r\n\tthis.tiXML2object = function(nodeList,isRoot)\r\n\t{\r\n\t\t\r\n\t\t\tif(typeof(isRoot) === \"undefined\")\r\n\t\t\t\tisRoot = false;\r\n\t\t\r\n\t\t\tvar nodeListLenght \t= nodeList.length;\r\n\t\t\t\r\n\t\t\t//Ti.API.info(\"tiXML2object start\");\r\n\t\t\t\r\n\t\t\tif(nodeListLenght > 0)\r\n\t\t\t{\r\n\t\t\t\r\n\t\t\t\tif(isRoot===true)\r\n\t\t\t\t\tvar returnArray \t= Array();\r\n\t\t\t\telse\r\n\t\t\t\t\tvar returnArray \t= new Object();\r\n\t\t\t\t\t\r\n\t\t\t\tfor(var i=0;i 0)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tvar fChild = children.item(0);\r\n\t\t\t\t\t\t\t//Ti.API.info(fChild);\r\n\t\t\t\t\t\t\t//Ti.API.info(fChild.getNodeType());\r\n\t\t\t\t\t\t\tif(!fChild )\r\n\t\t\t\t\t\t\t\tcontinue;\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\tif( fChild.getNodeName() == \"text\")\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\treturnArray[item.getNodeName()] = fChild.getNodeValue();\t\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\tvar tChilds = item.getChildNodes();\r\n\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\tif(isRoot===true)\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\treturnArray.push( this.tiXML2object(tChilds) );\r\n\t\t\t\t\t\t\t\t\t//Ti.API.info(\"ROOT ENTRY \"+i) ;\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t\telse\r\n\t\t\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\t\t\treturnArray[item.getNodeName()] = this.tiXML2object(tChilds);\r\n\t\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\t}\t\r\n\t\t\t\t\t\t}\t\r\n\t\t\t\t\t\telse\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\treturnArray[item.getNodeName()] = item.getNodeValue();\t\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t}catch(e)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tTi.API.info(e);\r\n\t\t\t\t\t}\r\n\t\t\t\t\t\r\n\t\t\t\t\titem = null;\r\n\t\t\t\t\tchildren = null;\r\n\t\t\t\t}\t\r\n\t\t\t\treturn returnArray;\t\t\r\n\t\t\t\r\n\t\t\t}\r\n\t\t\treturn false;\r\n\t\r\n\t}\r\n\t\r\n\tthis.ccdsImage\t= function(imgSrc,imgHeight,imgWidth,imgQuality)\r\n\t{\r\n\t\tvar CRH = this; // C R H = ccds rest handler\r\n\t\t\r\n\t\tvar RESTclient = Ti.Network.createHTTPClient();\r\n\t\r\n\t\tRESTclient.onload = function()\r\n\t\t{\r\n\t\t\t//Ti.API.info('ccds xml ' + this.responseXML + ' text ' + this.responseText);\r\n\t\t\tvar doc = this.responseXML.documentElement;\r\n\t\t\tvar elements = doc.getElementsByTagName('image');\r\n\t\t\tvar objArray = CRH.tiXML2object(elements);\r\n\r\n\t\t\tCRH.onReady(objArray);\r\n\t\t};\r\n\t\t\r\n\t\tif(typeof(imgSrc) != \"undefined\")\r\n\t\t\timgSrc = \"&src=\"+imgSrc;\r\n\t\telse\r\n\t\t\timgSrc = false;\r\n\r\n\t\tif(typeof(imgHeight) != \"undefined\")\r\n\t\t\timgHeight = \"&height=\"+imgHeight;\r\n\t\telse\r\n\t\t\timgHeight = \"\";\r\n\r\n\t\tif(imgWidth != \"undefined\")\r\n\t\t\timgWidth = \"&width=\"+imgWidth;\r\n\t\telse\r\n\t\t\timgWidth = \"\";\r\n\t\t\t\r\n\t\tif(typeof(imgQuality) != \"undefined\")\r\n\t\t\timgQuality = \"&quality=\"+imgQuality;\r\n\t\telse\r\n\t\t\timgQuality = \"\";\r\n\r\n\t\tif(imgSrc !== false )\r\n\t\t{\r\n\t\t\treqURL = this.rest_url\r\n\t\t\t\t\t\t\t\t+\"?action=1\"\r\n\t\t\t\t\t\t\t\t+imgSrc\r\n\t\t\t\t\t\t\t\t+imgHeight\r\n\t\t\t\t\t\t\t\t+imgWidth\r\n\t\t\t\t\t\t\t\t+imgQuality;\r\n\t\t\t\t\t\t\t\t\r\n\t\t\tTi.API.debug(reqURL);\r\n\t\t\tRESTclient.open(\r\n\t\t\t\t\t\t\t'GET',\r\n\t\t\t\t\t\t\treqURL\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t\t\t\t\r\n\t\t\tRESTclient.send();\t\t\t\r\n\t\t}else\r\n\t\t\tCRH.onError('Image Src missing');\r\n\t}\r\n\t\r\n};\r\n{code}\r\n\r\n{code:title=importer_controller.js}\r\nCA.CONTROLLER.Importer = (function()\r\n{\t\t\t\r\n\r\n\tfunction convert_gps_to_gmap($string)\r\n\t{\r\n\t\tvar\t$gps = $string.split(\";\");\r\n\r\n\t\tvar $grad = $gps[0].replace(',', '.');\r\n\t\tvar $min = $gps[1].replace(',', '.');\r\n\t\tvar $sek = $gps[2].replace(',', '.');\r\n\t\r\n\t\tvar $result = 0;\r\n\t\tif( !isNaN($grad) && !isNaN($min) && !isNaN($sek) ) \r\n\t\t{\r\n\r\n\t\t\tvar $sek_part = $sek / 60;\r\n\t\t\tvar $min_part = $sek_part + parseInt($min);\r\n\t\t\tvar $min_part = $min_part / 60;\r\n\t\t\t$result = parseInt($grad) + $min_part;\r\n\t\t\t$result = $result.toString().split(\".\");\r\n\t\t\t\r\n\t\t\t$result = $result[0]+\".\"+$result[1].slice(0,5);\r\n\t\t}\r\n\t\treturn $result;\r\n\t}\r\n\r\n\tfunction saveCampgroundObj($cg)\r\n\t{\t\t\r\n\t\tTi.API.info(\"saveCampgroundObj($cg)\");\r\n\t\tvar $cg_id \t= $cg.obj_id;\r\n\t\tvar $cg \t= $cg.CONTENT;\r\n\t\t\r\n\t\tvar $newEntry = CA.MODEL.Campground.newRecord(\r\n\t\t\t{\r\n\t\t\t\tid : \t\t\t$cg_id,\r\n \t\t\t\tname: \t$cg.cls_campingplatz_name ,\r\n \t\t\tdescription: \t$cg.cls_campingplatz_platzbeschreibung,\r\n \t\t\tgeo_lat:\t convert_gps_to_gmap($cg.cls_campingplatz_coordinate_x),\r\n \t\t\tgeo_lng\t:\t convert_gps_to_gmap($cg.cls_campingplatz_coordinate_y)\r\n\t\t});\r\n\t\t\r\n\t\treturn $newEntry.save();\r\n\t}\r\n\t\r\n\tfunction saveCampgroundObjs($cgArray) \r\n\t{\r\n\t\tvar $errorCount = 0;\r\n\t\tvar index= 0; \r\n\t\tfor(index in $cgArray)\r\n\t\t{\r\n\t\t\tvar $cg = $cgArray[index];\r\n\t\t\t\r\n\t\t\tif( saveCampgroundObj($cg) )\r\n\t\t\t{\r\n\t\t\t\tTi.API.info('saveCampgroundObj erfolgreich');\r\n\t\t\t}else\r\n\t\t\t{\r\n\t\t\t\t$errorCount = $errorCount+1;\r\n\t\t\t\tTi.API.info('saveCampgroundObj fehlgeschlagen');\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tif($errorCount > 0)\r\n\t\t\t{\r\n\t\t\t\tTi.API.info('Es konnten '+$errorCount+' Campingplaetze nicht gespeichert werden.');\r\n\t\t\t}\t\r\n\t\t}\r\n\t}\r\n\r\n\treturn{\r\n\t\t\r\n\t\trefresh: function()\r\n\t\t{\r\n\t\t\tvar $currentOffset = 0;\r\n\t\t\tvar $limit = 5;\r\n\t\t\t\r\n\t\t\tTi.API.info(\"CA.CONTROLLER.Importer refresh-func : start\");\r\n\t\t\tvar caHandler = new ccdsRestHandler();\r\n\t\t\t\r\n\t\t\tcaHandler.onReady = function(array)\r\n\t\t\t{\r\n\t\t\t\tTi.API.info(\"GOT \"+array.length+\" ENTRIES\");\r\n\t\t\t\tif(array.length > 0)\r\n\t\t\t\t{\r\n\t\t\t\t\tsaveCampgroundObjs(array);\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\t\t\t\tTitanium.App.fireEvent(\"refreshCampgrounds\");\r\n\t\t\t\t$currentOffset = $currentOffset+$limit;\r\n\t\t\t\tif($currentOffset <= 90)\r\n\t\t\t\t{\r\n\t\t\t\t\tTi.API.info(Titanium.Platform.availableMemory);\r\n\t\t\t\t\tsetTimeout(function()\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tTi.API.info(\"TIMER TRIGGERS \"+Titanium.Platform.availableMemory);\r\n\t\t\t\t\t\tcaHandler.ccdsQuery(\"CAMPINGPLATZ\",L(\"lang_id\"),false,$limit,$currentOffset);\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t},5000);\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tTi.API.info(\"INIT \"+Titanium.Platform.availableMemory);\r\n\t\t\tcaHandler.ccdsQuery(\"CAMPINGPLATZ\",L(\"lang_id\"),false,$limit);\r\n\t\t\tTi.API.info(\"CA.CONTROLLER.Importer refresh-func : end\");\r\n\t\t}\r\n\t};\t\r\n})();\r\n{code}\r\n\r\n\r\nh4.Console Output\r\n{noformat}\r\n[INFO] Titanium SDK version: 1.7.1\r\n[INFO] iPhone Device family: universal\r\n[INFO] iPhone SDK version: 4.3\r\n[INFO] iPhone simulated device: iphone\r\n[DEBUG] executing command: /usr/bin/killall iPhone Simulator\r\n[DEBUG] No matching processes belonging to you were found\r\n[DEBUG] finding old log files\r\n[DEBUG] executing command: mdfind -onlyin /Users/egomez/Library/Application Support/iPhone Simulator/4.3 -name 60568302-d2e0-4b16-8467-ed4a6c54c034.log\r\n[INFO] Launching application in Simulator\r\n[INFO] Launched application in Simulator (12.05 seconds)\r\n[DEBUG] executing command: xcodebuild -version\r\n[DEBUG] Xcode 4.0.2\r\n[DEBUG] Build version 4A2002a\r\n[INFO] Found 4.3.2 patch installed\r\n[INFO] Application started\r\n[DEBUG] reading stylesheet from: /Users/egomez/Library/Application Support/iPhone Simulator/4.3.2/Applications/50DD44C4-A986-4AE6-9602-4695BDC53B15/Ticket9779.app/stylesheet.plist\r\n[INFO] Ticket9779/1.0 (1.7.1.1293a6d)\r\n[DEBUG] Analytics is enabled = YES\r\n[DEBUG] loading: /Users/egomez/Documents/Titanium Studio Workspace/Ticket9779/Resources/app.js, resource: Users/egomez/Documents/Titanium Studio Workspace/Ticket9779/Resources/app_js\r\n[DEBUG] include url: file://localhost/Users/egomez/Documents/Titanium%20Studio%20Workspace/Ticket9779/Resources/ccdsRestHandler.js\r\n[DEBUG] loading: /Users/egomez/Documents/Titanium Studio Workspace/Ticket9779/Resources/ccdsRestHandler.js, resource: Users/egomez/Documents/Titanium Studio Workspace/Ticket9779/Resources/ccdsRestHandler_js\r\n[INFO] ccdsRestHandler ccdsQuery-func CAMPINGPLATZ,1,false,40\r\n[INFO] $rest_url : http://www.vcwmv.de/ccds_extensions/ccdsModules/ccdsREST/index.php?action=0&ccdsclass=CAMPINGPLATZ&lang_id=1&limit=40\r\n[DEBUG] application booted in 22.933006 ms\r\n[INFO] RESTclient.onload loaded\r\n[DEBUG] App Spec: specified by path /Users/egomez/Documents/Titanium Studio Workspace/Ticket9779/build/iphone/build/Debug-iphonesimulator/Ticket9779.app\r\n[DEBUG] SDK Root: path=/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk version=4.3 name=Simulator - iOS 4.3\r\n[DEBUG] using device family iphone\r\n[DEBUG] Session started\r\n[DEBUG] Session did end with error (null)\r\n[INFO] Application has exited from Simulator\r\n{noformat}\r\n\r\nh4.Associated HD ticket\r\nhttp://appc.me/c/APP-147769\r\n\r\nh4.Additional info\r\nLet me know please if further data is required or this issue should be opened at a different Jira report, thanks. ", "updateAuthor": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2011-08-12T06:34:26.000+0000", "updated": "2011-08-12T06:34:26.000+0000" }, { "id": "176495", "author": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Fixed in the 1.8.0.1 release. Duplicate of many other tickets about XML functionality.", "updateAuthor": { "name": "stephentramer", "key": "stephentramer", "displayName": "Stephen Tramer", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-12-19T10:19:23.000+0000", "updated": "2011-12-19T10:19:23.000+0000" }, { "id": "415697", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closing ticket as duplicate with reference to the linked issues.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-24T18:39:12.000+0000", "updated": "2017-03-24T18:39:12.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }