Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.)

  • #2
    Regular Coder
    Join Date
    Aug 2010
    Posts
    972
    Thanks
    19
    Thanked 212 Times in 210 Posts

  • #3
    New to the CF scene
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •