CSL as JSON?

I wonder: is there any value in using a JSON representation of CSL
styles for certain processing circumstances?

I’m thinking about the fact that:

  1. XML is kind of a pita in the javascript world (namely, support is
    inconsistent)
  2. the CSL editor code has to convert back-and-forth to a JSON representation?

Here’s a gist with a simple Ruby script to convert the style, and the
result using APA.

https://gist.github.com/867583

Bruce

And related …

I guess while I’m at it and frustrated with inconsistent namespace
support in different XML tools*, what are the trade-offs in dropping
use of a namespace?

The namespace was kind of necessary in the all XML workflow CSL began
in, and we now have legacy issues that make contemplating these sorts
of changes painful, but I don’t think it’s necessary in 2011, and it
would make things easier in some ways.

Bruce

  • For example, as far as I can tell, the REXML library in the Ruby
    standard library still doesn’t do this right, despite the fact that I
    reported a bug (IIRC) years ago.

I may be wrong, but it seems to me that any XML parsing library that doesn’t support namespaces is useless for parsing virtually any standards-based format, since they all use namespaces.

Simon

I’m not sure whether either of these is really be a big deal. Browser support for XML is not all that bad. Modern browsers (Firefox, Chrome, Safari, Opera, IE 9) support DOMParser and XMLHttpRequest, and older versions of IE can be made to support both of these with <10 lines of code. I’m also not sure that XML parsing is really a performance bottleneck. CSL styles are generally pretty small relative to e.g. a webpage, so there isn’t much data to parse. I don’t know what the overhead is for DOM XML/E4X API calls, but I assume it’s not too big, and this is something we could profile.

If we did want to convert to JSON, I think we’d need a different representation than what you have here, as it seems like you’ve realized, but I’m not convinced this is worth the effort.

Simon

I wonder: is there any value in using a JSON representation of CSL
styles for certain processing circumstances?

I’m thinking about the fact that:

  1. XML is kind of a pita in the javascript world (namely, support is
    inconsistent)
  2. the CSL editor code has to convert back-and-forth to a JSON representation?

I’m not sure whether either of these is really be a big deal.

Fair enough.

I may be wrong, but it seems to me that any XML parsing library that doesn’t support namespaces is useless for parsing virtually any standards-based format, since they all use namespaces.

Yeah, but they don’t all do it correctly. But maybe libraries in that
category are more of a minority than I was worrying about.

Bruce