Structure to File Request

mattgolsen's picture

I noticed with the "Kineme Structure to File" patch, that when it saves as structure, that it reorders it into alphabetical order. Is there a way thatan option can be added to disable this behavior?

The reason I ask is that I'm having to shoe in some fault tolerance into a project that runs on an unreliable network, so I'm building an XML caching system that will save this XML feed locally and only update the display when a newer version of the feed is downloaded. The problem being is that since Structure to File alphabetizes the contents of the feed when it saves it, it reorders the values throughout the entire composition.

Is there something else maybe I'm missing that would be a better way to handle this?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.'s picture
Re: Structure to File Request

Trick is to key your XML structure with tags that are meaningful ie. give the order you want. Then you can pull items by relevant unique key. Either that or use Javascript to iterate and find the item index by testing for a unqiue data value inside object somewhere.

This question has made me realise there is no patch to find an element/item inside a structure by matching a data vaue, only index (problematic*) and key.

*creating structures by iterating in Javascript results in a structure with jumbled index order so keys are required in many cases.

smokris's picture
Re: Structure to File Request

Standard Cocoa NSDictionarys are unordered; standard Cocoa NSArrays are unkeyed. Internally, QC Structures are represented as GFLists, a special QC-specific type that allows data to be both ordered and keyed.

Currently Structure To File is converting the structure to an NSDictionary, then writing it to disk. Structure From File does similarly. This is why you're seeing the reordering.

I just published a new FileTools beta, in which Structure To File and Structure From File have been modified to save the structure with an alternate encoding, preserving order.

mattgolsen's picture
Re: Structure to File Request

Thanks so much for this, this is going to help immensely.

mattgolsen's picture
Re: Structure to File Request

Your realization is actually a challenge I'm going to have to attack in the near future. I'm pulling an XML feed from MS SharePoint, which I'm going to have to compare to another feed, and generate a new structure from that. It's going to be exciting.

Thankfully SharePoint is somewhat nice in the feeds it generates:

[geshifilter-xml xmlns:s='uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882'
<s:Schema id='RowsetSchema'>
   <s:ElementType name='row' content='eltOnly' rs:CommandTimeout='30'>
      <s:AttributeType name='ows_Attachments' rs:name='Attachments' rs:number='1'>
         <s:datatype dt:type='boolean' dt:maxLength='1' />
      <s:AttributeType name='ows_LinkTitle' rs:name='Location' rs:number='2'>
         <s:datatype dt:type='string' dt:maxLength='512' />
   <z:row ows_Attachments='0' ows_LinkTitle='Column Name' ows_Column_x0020_Name='' ows_Column_x0020_Name2=''  />

Which is super handy because it gives a description of the data in the "Schema id" section, which allows me to automatically create the names and category titles for the stuff that's under the data section "z:row".