Posts Tagged ‘xml’

Elegant “contentEditable” Solution for XML

Wednesday, April 13th, 2011

If you’ve ever wanted to do WYSIWYG editing of XML in a browser, I think you’re going to like the elegant solution I stumbled across.  The idea actually culminated from reading Kurt Cagle’s excitement around XQuery in the Browser, and my desire to create a MLUC DemoJam entry that could excite publishers about my latest passion, HTML5.  At first I thought XQuery in the Browser opened a new possibility to do simple browser-based WYSIWYG editing, but as I dug into it I found it was much simpler to do the XSLT in MarkLogic, with granular pointers attached to each editable XML node.  This solution allows me to very simply and efficiently:

  • Render XML to final HTML using existing XSLT
    • only minor modifications are required to add “sourcePath” attributes to the HTML
    • MarkLogic’s xdmp:path function makes it simple to get precise paths to the source XML content
  • Allow WYSIWYG editing of the XML directly from the browser
    • HTML5′s contentEditable attribute makes this simple
  • Use very efficient AJAX calls for immediate update to the source XML document
    • MarkLogic’s xdmp:node-replace allows pin-point updates of only the changed node

All this in less than 100 lines of code!  The video below does better justice to what I’m talking about:

Please note that I’m not trying to demo a full-featured editor here.  This is just a proof of concept.  Obviously many features need to be added before this is usable.  Nevertheless, this simple demo shows an approach that could enable many highly usable solutions for publishers.

MarkLogic? A “NoSQL” Database? YES!

Wednesday, April 14th, 2010

The NoSQL movement had been garnering a lot of attention recently. It’s a trend largely facilitated by the changing demands of the transactional web. Today, the web is bidirectional and much more content oriented than it was in years past. The amount of user generated content has increased exponentially and relational databases are not tailored to handle massive amounts of semi-structured content.

One NoSQL option that we at Avalon are very excited about is Marklogic. Some will argue that it does not fit into their definition of “NoSQL,” but Mark Logic CEO Dave Kellogg did a good job of positioning Marklogic as a relational database alternative (aka NoSQL) in a post last week.

Recently I’ve been spending a lot of time exploring how Marklogic, as a powerful document (yes, key [aka URI] – value) and XML database, can be used to support social media and user generated content use cases. For example, threaded comments are much more naturally represented in a hierarchical, ordered format like XML. Marklogic and xQuery make it easier to store, manipulate, and search these data structures.

To demonstrate, I built a simple element reordering example using Marklogic and jQuery. Even this simple example would be non-trivial in a traditional relational model where lists and order with respect to other elements are unnatural at best.



So this is obviously a super simplified example, but hopefully it gives you a small glimpse into one of the capabilities greatly simplified by Marklogic through XML and xQuery.

I will be at the MarkLogic User conference in San Francisco May 4-6th. I hope to see you there!