简体   繁体   中英

Loading HTML fragments asynchronous in a web page that is generated using XSLT & XML

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM