Search

Hi! I have a problem with XSLT and probably with data sources as well.

I have a "A" item that has a select box link pointing to a "B" item that has a select box link that points to a "C" item.

I want to get all "A" items by "C" as follows:

Elements in C1: A1, A4, A6 Elements in C2: A5, A9, A10

But C is not directly linked to A because B is like the bridge that joins A and C. In other words, I need to get A only if B has C.

In my data source: I'm getting the different nodes for each, for A, B and C. I'm not using any filter, the information is there, what I have to do now is to join it with XSL. But I'm wondering if there is any other option in the data source I'm missing out, or if this is possible to use the filters for this...

I did a lot of thinking, and even tried, but I find myself stuck in a cycle inside a cycle inside a cycle of <xsl:if>, I also tried <xsl:for-each>...

Thanks!

I guess Data Source Chaining is what you're looking for?

It sounds like it.

In the filters field in the data source section, what's the right way of using a filter?

For example, PRODUCT (A) has a CLIENT (B), and client has COUNTRY (C), that country has an STATES field.

How is the product datasource supposed to be filtered? And about the country, something like (filter by system ID): {$ds-client.country}, but there is where I miss the chain.

Unfortunately the page you sent me doesn't cover this topic in a deep way...

I have a "A" item that has a select box link pointing to a "B" item that has a select box link that points to a "C" item.

I want to get all "A" items by "C".

You have a datasource for C, which is filtered by whatever field you need. C returns its ID as an Output Parameter $ds-c.id.

You have another datasource for B, which is filtered by {$ds-c.id} on the corresponding Select Box Link field. B also returns its ID as an Output Parameter $ds-b.id.

Same for A, which is filtered by {$ds-b.id}.

If you want A only to be executed if B returns a result, you can require $ds-b.id as a Required URL Parameter under Output Options in your datasource.

I had all of that set already. I'm getting A nodes, B and C nodes. So I guess my question was more related with XSL. Actually, what I need to do is to list all the C items, and under the C items list all the A items whose B has that current C in the select box link.

I know I can create variables and also loops in XSL, but certainly I'm quite new to this language. What I have in mind is the following:

  • Use <xsl:for-each> to read all the C items (to create a tabbed content, where each tab corresponds to the current C item)
  • Here is where I get stuck, no idea how to retrieve the A items based on if they have a B that has the current C. :/

I did a workaround to group the B items by C, but A continues outside the grouped nodes, I guess there is no way to get A into that group. However, this is a more useful XML structure, I'll figure out how to get all A items arranged by C.

Thank you for helping me out (again), Jens! :)

Actually, what I need to do is to list all the C items, and under the C items list all the A items whose B has that current C in the select box link.

Ah ok, much clearer now.

What about something like this?

<xsl:for-each select="datasource-c/entry">
    <xsl:for-each select="../../datasource-b/selext-box-link-c[@id = current()/@id]">
        <xsl:for-each select="../../datasource-a/selext-box-link-b[@id = current()/@id]">
            ...
        </xsl:for-each>
    </xsl:for-each>
</xsl:for-each>

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details