If you're interested in functional programming, you might also want to checkout my second blog which i'm actively working on!!

Tuesday, November 29, 2011

Using client side XSLT with Saxon-CE

Yesterday I decided to have a go with Saxon-CE as I definitely can see benefits from doing client side transformations. Saxon-CE is still in alpha state so it is not recommended to use it in production yet.
I wanted to really come up with a nice demo so decided to check if I could build a webpage using live Twitter Search data. I did face my first issue as the @data-source attribute is not working cross-domain and it does not even seem to be working in chrome or IE. I had to manually download the XML results from a Twitter search for Michael Kays tweets. They are included in this downloadable zip but to get an idea of what the data looks like you can open following url: Michael Kay's tweets

The final result can be seen in screenshot below:

4 comments:

  1. An interesting demo for Saxon-CE. I'm working for Saxonica on the next Alpha release of Saxon-CE so I've tried this out on the pre-release build: Your XSLT runs fine on the latest releases of IE, Firefox, Opera and Chrome. Legacy versions of IE will however throw an error when adding the style element found in your template.

    On cross-domain policy - you will face the same issues as JavaScript. However, the next alpha release fixes ixsl:eval and works by injecting a script element with a new function into the DOM and then evaluating the function; it's just possible therefore that that JSONP trick you mention could be made to work.

    I will look into the issue that required you to wrap your result-document target div elements within an enclosing div.

    Finally, we're adding links to Saxon-CE samples on the Saxon-CE website, so please let us know if it's ok for us to add a link to this.

    Thanks

    Phil Fearon
    phil@saxonica.com

    ReplyDelete
  2. It turns out HTML5 parsing accounts for the issue you experienced with the div tags which were self-closing. HTML5 parsers just see these as an element open tag, so the following div element which appears to an XML parser to be a sibling is, in HTML, parsed as a child and therefore replaced due to the 'replace-content' in the XSLT.

    To fix this, just write out the place-holder div elements with a start tag and a close tag and no content.

    ReplyDelete
  3. Hi Phil,
    Is it perhaps an option to somehow take a look at the non-compressed javascript sources. The only reason i'm asking is because I actually already started thinking about doing an advanced mashup demo but that would require JSONP alike functionality. And it would also help if we could debug the code but now it is really hard to do so.

    ReplyDelete
    Replies
    1. Robby,
      There's no plan to make the non-compressed javascript sources generally available - but you could try submitting a request to Saxonica if you have a specific need.

      On code debugging, a modal popup message box did make things rather awkward. The first beta release (Feb 2 2012), brings more diagnostics in the form of configurable error and event logging to the browser developer console - such as Firebug.

      Delete