It does make sense if there's an element(UtilityLinks) between the root-element($currentPage) and the UtilityLink-element. The following examples would probably work as well I think:
So, when you're on the Homepage of your site, that's what $currentPage will be, the Homepage.
From there you want to go down the content tree, through the UtilityLinks node to all the UtilityLink nodes. That is, $currentPage/UtilityLinks/*
If you want to simply look for all the UtilityLink nodes you could do any of the following which are all basically equivalent:
$currentPage/descendent::*[name()='UtilityLink']
$currentPage//*[name()='UtilityLink']
$currentPage//UtilityLink
Of course, descendent-or-self (the short-hand is '//') is slower than specifying the full path but unless you've got a boat load of nodes you're unlikely to notice it. Still, keep it in mind; you want to specify as much as you can to get maximum performance.
Thanks Doug, it makes total sense now. Unless we have a HUGE site, I typically want to be as "unspecific" as possible in case the structure of the content changes. In this case though, it's a matter of being rusty :)
XPath Filtering not working
This is a strange one that I've never seen before. The following returns nothing for me:
But this does:
What gives? Thanks!
Ps. I'm sure it must be something dumb that I am just missing after having looked at it for a few hours.
Let's start at step zero... what's the (simplified) output of:
Basically, I want to see the xml you have to work with. Likewise, what's the content tree you see? Obviously they should coincide completely, do they?
cheers,
doug.
Hi Nik
It does make sense if there's an element(UtilityLinks) between the root-element($currentPage) and the UtilityLink-element. The following examples would probably work as well I think:
Either way, I'd probably use the solution you provided in your first post anyway :)
/Kim A
Sweet, I have THE man looking at this. Cool :)
So, here's my output fom copy-of (rather long)
Doing a copy-of on $currentPage/* [name()='UtilityLink'] produces nothing. What did I miss?
Thanks Doug!
Ah Kim, you got it! Of course the // works as opposed to single /. I've been away too long :(
Thanks a bunch!
-- Nik
Ps. Does that make the built-in template for List Subpages by Document Type wrong then?
The answer is simple... your xpath works against your xml and your xml has the following (very simplified):
So, when you're on the Homepage of your site, that's what $currentPage will be, the Homepage.
From there you want to go down the content tree, through the UtilityLinks node to all the UtilityLink nodes. That is, $currentPage/UtilityLinks/*
If you want to simply look for all the UtilityLink nodes you could do any of the following which are all basically equivalent:
Of course, descendent-or-self (the short-hand is '//') is slower than specifying the full path but unless you've got a boat load of nodes you're unlikely to notice it. Still, keep it in mind; you want to specify as much as you can to get maximum performance.
cheers,
doug.
Aaaaaand... Kim types faster than I do! :)
Nice work Kim!
cheers,
doug.
Thanks Doug, it makes total sense now. Unless we have a HUGE site, I typically want to be as "unspecific" as possible in case the structure of the content changes. In this case though, it's a matter of being rusty :)
Thanks to both of you!
-- Nik
is working on a reply...