Noobie here, scratching my head.
This is an open discussion with 9 replies, filed under XSLT.
Search
On some of the pages you may be forgetting to call the relevant data sources for each page.
I don’t think that is it. To get the splash image to work it is pulling from the “Page” data source. All my pages I am trying this with have that set up properly, my issue seems to be that it’s pulling extra data, not just limiting it to the entry ID I am trying to use.
This should work.
<xsl:apply-templates select="/data/page/title/entry[@id = '13']/splash-image" /> <xsl:template match="/data/page/title/entry/splash-image"> </xsl:template>
When you see the content being spat out like this it means you are performing an apply-templates select="..."
on an element, but you haven’t got any template match="..."
matches fo that element.
Try reducing your match
just to the node name you’re matching on:
<xsl:template match="splash-image">
And is the file in which the above match
is in definitely included in your page?
@nickdunn
Could you explain more?
@brendo
So maybe I am not understanding select and match entirely, what is the difference?
Well… your select
should always more precise than your match
. Otherwise you’ll end up with selecting a few items that don’t have a matching template, defaulting to <xsl:value-of select="*" />
.
Mathematically speaking, your expression has to be a surjective function. :-)
@phoque I am a designer, so, bringing math terms isn’t helping haha :) That being said I am still trying to understand this as much as I can. So, my select should be more specific than my match? What would that look like?
select="/data/page/title/entry[@id='13'] match="/data/page/title/entry[@id='13']/splash-image
Something more like that? Not sure if I am following this concept practically, or why what I have above is outputting splash elements outside of the [@id=’13’] parameter I set.
Specific selects let you select special parts of the tree while specific matches let you formulate exceptions to your templates.
And to explain your example:
select="/data/page/title/entry[@id='13'] match="/data/page/title/entry[@id='13']
They may “accidentally” have the same attribute expressions but it’s no different than
select="/data/page/title/entry[@id='13'] match="/data/page/title/entry
Except… when you have
select="/data/page/title/entry match="/data/page/title/entry match="/data/page/title/entry[@id='13']
In this case, all entries will be matched by the first template and only the one with id=13 will be matched by the second one.
Hmmm, I am going to have to re-read some of this and revisit my code. Thanks for all your help, my brain is on the verge of having the basics ‘click’.
Maybe this will help, so when I use entry[@id=’2’] is that more saying:
look in entry for anything that has an attribute with the integer 2 in it
rather than what I was implying which would be:
only match and <entry> node who’s attribute id equals EXACTLY ‘2’ ?
Or am I misunderstanding how it could confuse entry[@id=’2’] with other nodes?
Create an account or sign in to comment.
I have dynamic splash images for each page on my site based on an image field. So, I have dug around and figured out the xslt to display the images. But, for some reason, it’s outputting a bunch of info that I don’t really know where it’s coming from. I am sure it’s something basic but it makes no sense to me.
Here is how I am calling up the template from my “master” utility.
And then on each page template this is how I am pulling up each splash image.
It seems to work fine, but, on some pages (and not others) I will get this weird output.
Any suggestions? I get that it is listing file names from other nodes in the xml, but I don’t get why, and I don’t get why it’s only doing the filename when {filename} is the only time I have declared it. Why is it showing up outside of my template?
Also, why did it put xmlns=”” into my div?