nicklockwood / XMLDictionary

[DEPRECATED]
http://charcoaldesign.co.uk/source/cocoa#xml-dictionary
Other
1.14k stars 235 forks source link

ordering of children is incorrect? #26

Closed apanagar closed 10 years ago

apanagar commented 10 years ago

I've got an issue with the ordering of child nodes. Is ordering intended to be preserved or am I just doing something wrong?

Here's my xml:

<xpobjEdit id="" type="" backgroundColor="#CDCDCD" height="400px" width="100%">
        <editForm>
            <assetEdit id="" height="240px" width="100%"/>
            <textEdit name="name" attribute="name" label="Name" placeholder="Name" value="catdog"/>
            <longTextEdit name="description" attribute="description" label="Description" placeholder="Description" value="monkey elephant"/>
            <textEdit name="tags" attribute="tags" label="Tags" placeholder="(separate tags with commas)" value=""/>
            <locationCoordinateEdit name="location" label="Location" placeholder="" mapbutton="true" mapbuttonDisabled="true" value=""/>
        </editForm>
        <buttonBasic label="PREVIEW" color="#FFFFFF" backgroundColor="#CCCCCC" width="100%" align="center">
            <onClickCallback type="xperienceNavigate" xperience="$this" templateId="TBD" viewTransition="push:fromRight"/>
        </buttonBasic>
    </xpobjEdit>

and here's the result:

{
    "__name" = xpobjEdit;
    backgroundColor = "#CDCDCD";
    buttonBasic =     (
                {
            align = center;
            backgroundColor = "#CCCCCC";
            color = "#FFFFFF";
            label = PREVIEW;
            onClickCallback =             (
                                {
                    templateId = TBD;
                    type = xperienceNavigate;
                    viewTransition = "push:fromRight";
                    xperience = "$this";
                }
            );
            width = "100%";
        }
    );
    editForm =     (
                {
            assetEdit =             (
                                {
                    height = 240px;
                    id = "";
                    width = "100%";
                }
            );
            locationCoordinateEdit =             (
                                {
                    label = Location;
                    mapbutton = true;
                    mapbuttonDisabled = true;
                    name = location;
                    placeholder = "";
                    value = "";
                }
            );
            longTextEdit =             (
                                {
                    attribute = description;
                    label = Description;
                    name = description;
                    placeholder = Description;
                    value = "monkey elephant";
                }
            );
            textEdit =             (
                                {
                    attribute = name;
                    label = Name;
                    name = name;
                    placeholder = Name;
                    value = catdog;
                },
                                {
                    attribute = tags;
                    label = Tags;
                    name = tags;
                    placeholder = "(separate tags with commas)";
                    value = "";
                }
            );
        }
    );
    height = 400px;
    id = "";
    type = "";
    width = "100%";

In my case, the order of the children of editForm matter, but in the resulting dictionary doesn't preserve the order. I used the alwaysUseArrays flag as well. Maybe I have misunderstood it's purpose?

Thanks for the great work!

nicklockwood commented 10 years ago

NSDictionary doesn't preserve order of its keys, so this is expected behavior. For multiple nodes with the same name, the order should be preserved in the resultant array, but that's all.

apanagar commented 10 years ago

got it, thanks!