tags:

views:

246

answers:

2

Technology: Dot Net, ASP.Net

  • We have articles stored in XML repository and article contains multiple sections.

  • These XML files are transformed to HTML using XSLT for browser rendering.

  • New requirement is to allow users to comment on each section (not on the article!) and when the article is shown we also show the comments (but based his role/rights and in a collapsible/expandable widget)

  • Since comments are not directly related to article and also the same article can be shown in multiple sites; we will not be able to store comments along with article XML.

  • We plan to solve this by storing comments in a separate database with references and when transforming article XML using XSLT we will embedded a URLs to the comments in the generated html.

  • When user clicks on the comments widget, we use the embedded URL to fetch the comments using Asynchronous calls from the web server and show it in the expanded div area

This sounds very complex to us and not sure if this will work.

Please let me know if this can be archived? or suggest a better way to archive this. THX

A: 

It can work.

Embedded urls can have an onclick attribute that writes an iframe that sources a page on your server that displays the comments for that fragment of the article along with a form to submit new comments, if so desired.

I suggest iframes because of your statement "the same article can be shown in multiple sites" - and I assume you do not control all of them.

Dennis
We need more information in order to accurately answer your question. When you say "the same article can be shown in multiple sites" - are these sites that you control or not?
Dennis
Continuing on the assumption that you do not control all the sites on which the content will appear, Jeff Ober's suggestion would not work due to cross-domain security restrictions. Dynamic Script Tags would though.
Dennis
+1  A: 

It can certainly be done that way. You needn't even wait for a user to click the comment widget. Look at jQuery (http://www.jquery.com). It has ajax routines for loading pages piecemeal like a mashup (see http://docs.jquery.com/Ajax and http://docs.jquery.com/Ajax/load#urldatacallback).

However, why not add a second transformation for pages with comments that includes the comments data? Most XSLT libraries worth their salt let you set parameter and variable values.

I would not (as the previous poster suggested) use an iframe. They are ugly and a pain to work with in javascript. If you go the async route, use something akin to jQuery's load method, injecting HTML into a page.

Jeff Ober