Get a handle on RSS URL in XSL

Discussion in 'XML' started by dirvine, Nov 8, 2006.

  1. dirvine

    dirvine Guest

    I want to add a semi-static link in my RSS display page so people can
    subscribe to the feed. Note: I do not have control over the RSS feed
    itself, just the XSL used to transform (format) it.

    I use a {link} variable to get the url of the item (article) in my XSL
    file, however, I don't know how to get the url of the RSS feed itself.
    Technically, it's not part of the xml data itself so I'm a little
    stumped.

    We have a bunch of these, so I don't want to hard-code the URL into the
    XSL file.

    Is there a built-in variable that retrieves the RSS feed's URL?

    The desired result would look something like this:

    Blog Feed Title
    - First article
    - Second article
    - Third article
    Subscribe to this feed (link to rss url)
     
    dirvine, Nov 8, 2006
    #1
    1. Advertising

  2. dirvine wrote:
    > Is there a built-in variable that retrieves the RSS feed's URL?


    XSLT has no knowledge of RSS. Your RSS environment *may* pass that
    information in as a parameter or make it available as a function call,
    but you'll have to take that up with whoever wrote that software and/or
    is running that server.

    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
     
    Joseph Kesselman, Nov 8, 2006
    #2
    1. Advertising

  3. dirvine

    Andy Dingley Guest

    dirvine wrote:

    > I use a {link} variable to get the url of the item (article) in my XSL
    > file, however, I don't know how to get the url of the RSS feed itself.
    > Technically, it's not part of the xml data itself so I'm a little
    > stumped.


    Then you can't get it. XSLT takes one XML input document and applies an
    XSLT transform (also an XML document) to it. That's pretty much your
    lot - there's no useful "environment" to access properties from. You
    have the document() function, but that's really just swapping one XML
    input fragment for another. You can also get up to all sorts of
    mischief with extension functions, but they're likely to give you a
    complicated and unstable solution.

    In practice you have two viable options: First is to embed all the
    necessary information in the input XML document, and I mean
    _everything_. For heavy-duty CMS tasks, this is usually the best
    approach.

    Secondly you could use a parameter in the XSL. This may be preferable
    and more "lightweight" because your XSL transform engine might offer a
    simple API for setting it from outside the transform before you start,
    without having to re-parse / compile the stylesheet. Even if it
    doesn't, it's still just an XML document -- make the <xsl:param>
    element easy to locate (maybe using an id attribute) and then you can
    set it through an XML DOM after loading it, but before using it as a
    stylesheet (watch for performance hits though).
     
    Andy Dingley, Nov 8, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    770
    SpaceGirl
    Feb 25, 2005
  2. Motta
    Replies:
    1
    Views:
    533
    Andy Dingley
    Jun 9, 2004
  3. Replies:
    1
    Views:
    3,613
    A. Bolmarcich
    May 27, 2005
  4. Jake Barnes
    Replies:
    1
    Views:
    423
    Andy Dingley
    Nov 14, 2005
  5. Jonathan Groll
    Replies:
    1
    Views:
    280
    Kouhei Sutou
    Jun 27, 2009
Loading...

Share This Page