Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1371] Make Alloy less dependent on knowledge about Titanium APIs for parsing XML

GitHub Issuen/a
Affected Version/sn/a
Fix Version/sn/a
ReporterFokke Zandbergen
AssigneeBruce Wayne


ALOY-1363 got me thinking it would be good to make Alloy less dependent on knowledge about the Titanium APIs for parsing XML.


* Less dependant on certain Titanium versions (e.g. should <SplitView> map to Ti.UI.iPad or Ti.UI.iOS namespace?) * More prepared for future Titanium versions (e.g. ALOY-1356) * Cut down on [custom parsers](https://github.com/appcelerator/alloy/tree/master/Alloy/commands/compile/parsers) - in particular for proxy elements (those which map to parent properties instead of .add(), enabling the above as well as less possible points of failure (e.g. ALOY-1282) * Less magic and higher predictability of XML parsing for developers * Would allow modules to use proxy elements as well, with need for Alloy to know how (like we now hard-coded ti.map support).


* Drop [implicit namespaces](https://github.com/appcelerator/alloy/blob/master/Alloy/common/constants.js#L151) and always require developers to be in charge and thus conscious of which namespace or module they use via ns="Ti.UI.iOS" an module="ti.map". * Replace as much proxy elements as we can by adding support for generic <Array> and <Object> elements, accompanied by a new parentProperty to tell Alloy which parent property to assign it to:
  <Collection src="marker" />
  <Map module="ti.map"> 
     <Array parentProperty="annotations" dataCollection="marker">
        <Annotation module="ti.map" />
     <Object parentProperty="region" latitude="33.74511" longitude="-84.38993" latitudeDelta="0.01" longitudeDelta="0.01" />
* Add "parentMethod" attribute for the developer to override the default add(), which can also be used with the above:
  <Map module="ti.map">
    <Polygon module="ti.map" parentMethod="addPolygon" />
     <Array parentMethod="addAnnotations" dataCollection="marker">
        <Annotation module="ti.map" />


  1. Fokke Zandbergen 2016-03-18

    /cc [~fmiao] [~brentonhouse]
  2. Brenton House 2016-03-18

    I like either way, but I guess <Array parentProperty="annotations" parentMethod="addMyAnnotations"> would give us more support for property names that might not be valid xml element names.
  3. Fokke Zandbergen 2016-03-18

    Good argument! I updated the description to use just that.

JSON Source