Dan Newcome, blog

I'm bringing cyber back

Archive for April 2010

Jath – A JSON template language for XML processing

with 4 comments

On Saturday, I released a project called Jath that implements a technique for processing XML data that I have been playing with. The idea is to be able to write a concise declarative template in JSON that describes the desired Javascript object and apply the template to the source XML data.

Using a template like this:

[
  "//label",
  {
    id: "@id",
    added: "@added",
    address: {
      street: "address/street",
      city: "address/city"
    }
  }
]

we can transform XML

<labels>
  <label id='ep' added="2003-06-10">
    <name>Ezra Pound</name>
    <address>
      <street>45 Usura Place</street>
      <city>Hailey</city>
      <province>ID</province>
    </address>
  </label>
  <label id='tse' added="2003-06-20">
  ...
  </label>
...
</labels>

Into Javascript like this

[
  {
    id: "ep",
    added: "2003-06-10",
    address: {
      street: "45 Usura Place",
      city: "Hailey"
    }
  },
  {
    id:"tse",
    added: "2003-06-20",
    address: {
      street: "3 Prufrock Lane",
      city: "Stamford"
    }
  },
  ...
]

The current implementation now supports XML namespace prefixes in all browsers except Internet Explorer. Jath also offers full support for Mozilla, Chrome, Safari, and nearly full support for Opera.

More usage information is available on the Github project page Jath. More examples can be found by looking at the test cases in samples.html. All code is provided under the MIT open source license.

Written by newcome

April 19, 2010 at 11:44 pm

Posted in Uncategorized

Getting unstuck by trusting your process

leave a comment »

NYC - MoMA: Philip Johnson Architecture and De...
Image by wallyg via Flickr

Everyone has that looming project that either seems huge and foreboding or maybe it seems small and is progressing at an embarrassingly slow pace. Either way, it is easy to get stuck by over thinking things. One thing that a musician mentor of mine used to say was to trust your (creative|working) process and you’ll get back into the groove. ¬†This sometimes requires a lot of effort for those of us that can be obsessive about their work, and client budgets and time constraints can make things downright debilitating to think about.

Ironically, having had an extremely productive day or session previously can make things even more difficult, especially if you are results-driven. It can be very painful to see several hours slip by without much to show for it, but sometimes this time is necessary to just to get moving. The critical part is to do it and trust your process.

The trick to understanding what “process” really means in this context is that we aren’t referring to a predefined set of steps like a manufacturing process. Your work process is just the application of your own sensibilities to the tasks at hand. Nothing more, nothing less. You know how to do it, so get started and trust yourself.

I actually wrote this post after having burned a good part of a day trying to get myself back into a project that had been sailing along just the day before. It was just so counter-intuitive that I was having such a tough time getting my feet back into it that I stopped to think for a bit, and this post is what I came up with. Hopefully it helps someone out, and hopefully I will remember it the next time it happens to me.

Reblog this post [with Zemanta]

Written by newcome

April 16, 2010 at 5:35 pm

Posted in Uncategorized