Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-27-2011, 02:30 PM   PM User | #1
anamardoll
New to the CF scene

 
Join Date: Sep 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
anamardoll is an unknown quantity at this point
Question Javascript to run an XSLT on a webpage?

Complete and utter newb here, so I apologize in advance.

I'm trying to create a widget for a website that will show the Recent Comments, but will limit what is shown to 1 comment per unique thread. The idea being that the popular threads don't drown out the unpopular threads in the widget.

Alas, I do not know Javascript. I am, however, proficient in XSLT. So I mapped out a little transform to get (essentially) what I want, thus:

Input: http://anamardoll.disqus.com/latest.rss

XSLT:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
  <xsl:template name="RSS_Feed" match="rss">
    <xsl:value-of select="'&#xa;'"/> 
    <!-- ITERATE THROUGH ALL POST NODES -->
      <xsl:for-each select="//item">
      <!-- IF NOT PREVIOUSLY USED -->
      <xsl:if test="not(preceding-sibling::item/child::title/node() = current()/child::title/node())">
        <xsl:value-of xmlns:dc="http://purl.org/dc/elements/1.1/" select="child::dc:creator/node()"/>
        <xsl:value-of select="(' posted on &#xa;')"/>
        <xsl:value-of select="substring-after(child::title/node(), 'Ramblings: ')"/>
        <xsl:value-of select="('&#xa;')"/>
        <xsl:value-of select="child::link/node()"/>
        <xsl:value-of select="('&#xa;&#xa;')"/>
      </xsl:if>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>
Output:
Code:
Ana Mardoll posted on 
Twilight: It's All About The Protagonist, Baby
http://www.anamardoll.com/2011/09/twilight-its-all-about-protagonist-baby.html#comment-320798527

Thepepboy posted on 
eReader: Running CM7 on a Nook Color from SD Card (REPOST)
http://www.anamardoll.com/2011/07/ereader-running-cm7-on-nook-color-from.html#comment-320690496

Jckeeml posted on 
Narnia: The Clean and Tidy Poor
http://www.anamardoll.com/2011/09/narnia-clean-and-tidy-poor.html#comment-320649311

chris the cynic posted on 
Metapost: Newsletter Subscriptions
http://www.anamardoll.com/2011/09/metapost-newsletter-subscriptions.html#comment-320586205
(And here is why I say the output is "essentially" what I want -- I'd PREFER the links to be linked around the preceding texts, but that's an advanced step at this point in the game.)

Is there an easy way in Javascript to just invoke an XSLT on a webpage and display the results? I've read online that there is, but can find no examples that work for me. I do appreciate any help provided and thank you in advance!

(Also, for background: This will be going into the Blogger HTML/Javascript Widget tool, so... yeah.)
anamardoll is offline   Reply With Quote
Old 09-27-2011, 08:33 PM   PM User | #2
DaveyErwin
Regular Coder

 
Join Date: Aug 2010
Posts: 814
Thanks: 12
Thanked 168 Times in 166 Posts
DaveyErwin is on a distinguished road
http://www.w3schools.com/xsl/xsl_client.asp
DaveyErwin is offline   Reply With Quote
Old 10-01-2011, 01:40 AM   PM User | #3
anamardoll
New to the CF scene

 
Join Date: Sep 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
anamardoll is an unknown quantity at this point
Thank you. We ended up having to go this route.

http://www.anamardoll.com/2011/09/me...-comments.html

But you can mark this as ended. Thanks!
anamardoll is offline   Reply With Quote
Reply

Bookmarks

Tags
javascript, newb, xslt

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:31 PM.


Advertisement
Log in to turn off these ads.