2 users online. Create an account or sign in to join them.Users

Search

I couldn't find any info on how to link data sources provided by dynamic xml sources where no sections are involved. Let's say I have a data source "images" based on the dynamic xml provided by the URl=external-site.com/get-images Another data source "author-by-id" is based on the dynamic xml returned by the URL=external-site.com/get-author?id=12345 which returns an author by id. The "images" data source returns xml where author-id is one of the attributes of the image element (like <image ... author-id="12345">...</image>). How do I link these two sources so I can display images with their respective author information obtained from the "author-by-id" source?

Thank you,

This might work (haven't tested it)
Attach both dynamic datasources to your page

Then i think this xslt might work:

<xsl:template match="/">
<!-- call datasource 'images' -->
<xsl:apply-templates select="data/images/entry" />
</xsl:template>

<xsl:template match="images/entry">
    <img src="{image}" />
    <h1>author information</h1>
        <!-- applies the template on datasource 'author-by-id' matching the current '@author-id' parameter -->
        <xsl:apply-templates select="/data/author-by-id/entry[@id = current()/image/@author-id]" />

</xsl:template>

<xsl:template match="author-by-id/entry">

        <xsl:value-of select="author-details"/>

</xsl:template>

Thank you, Cremol. But I don't think it will work. In my question I indicated that the "author-by-id" data source can only be dynamically populated when we know the author-id (the URL is URL=external-site.com/get-author?id=12345). You code might work if I could link two data sources "images" and "authors" to the page where all the images and all authors would be known at the page generation time. Probably I want something like when XSLT populates images and encounters an author-id it goes out and calls a data-source with a parameter that corresponds to the author-id and then it has the XML data which it can apply. I am not sure if that's even possible with the current way dynamic data sources are made. Probably if data sources could chain themselves not at XSLT level but at the source level (when they retrieve data for themselves), and they could pass parameters to each other, then it would be possible. So far it seems possible for the "regular" data sources based on sections, but the dynamic sources are kind of like "second class" citizens. I hope I am wrong and there are ways to do it :)

Ahh, i see, you would somehow need to set the author-id attribute as a parameter that you could use to filter the "author-by-id" data source.
I am not sure you could do this in one page load.
What you could do is make a unique page to display the author information... (can't think of any other solution at the moment.):

<a href="author-information/{image/@author-id}">author information</a>

Where 'author-information' is your unique page and {image/@author-id} populates a url-parameter that can be used to use as a variable in your "author-by-id" data source...

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.2 or above
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.0 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details