Call-template and Xpath
This is an open discussion with 4 replies, filed under XSLT.
Search
Hi iltrico,
If you need to pull out the Cat name, you could try something like this in the context of your entry:
<param name='cat-id' select='category/item/@id' /> <value-of select='/data/categories/entry[@id = $cat-id]/name' />
But how could I achieve something like this from another context, like “articles/entry”.
What I’d really like to do is to access data/category from a template that matches data/articles; is it possible or am I missing some key xsl concept?
Unless I’m misunderstanding, you should be able to reference any node that you like from any context as long as you give an absolute path from the root by having a leading slash (as @ashooner has done above e.g. /data/categories….)
Now I got it, thanks a lot!
Create an account or sign in to comment.
Hi, I’m trying to merge the information from a section link and a section. I’ll elaborate.
In the site I’m working on two languages are displayed side by side. The section category contains the category name in both languages and is linked to the articles section.
From an article list page I need to display each article section in both languages. The xml I get from just the articles section only gives me one language so I need another DS to fetch both categories names, right?
Now, my xml look something like this
In my articles xsl I’d like to call a template every time I need to put a category name, something like this doesn’t work though.
When I call the template I’m in articles/entry, how do I get to categories in the xml?
ps. It doesn’t work either without the wild XPath selection/filter (I just wanted to see if you guys liked it)