Can't you traverse up one level starting from the current node, and traverse the parent node (and probably ignoring the current node, aka $currentPage) and child nodes (will probably need some recursive template to get all descendant nodes for each of the siblings)
As Dirk says, you can grab all siblings of a given node by selecting the children of the parent node:
<!-- Grab all siblings, including $currentPage -->
<xsl:variable name="allSiblings" select="$currentPage/../*[@isDoc]" />
<!-- Exclude $currentPage from the set -->
<xsl:variable name="siblingsOnly" select="$currentPage/../*[@isDoc][not(@id = $currentPage/@id)]" />
- those variables have access to the individual nodes' children (and grandchildren, ancestors etc.) - just use the standard XPath axes to get to them.
To me, it just looks like you've forgot to add current() to get the publicationDate for the current item in the for-each (in the second half of the comparison).
Also: If publicationDate is a standard xmlDate field (e.g. something like: "2011-12-28T12:34:00+0200") there's no need to use extension functions to extract the data you need - example code below:
My bad - this is very tricky; in that exact setting, you should not use current() - this works for me, but it's really just using substring() instead of the extension function:
How to get all sibling nodes and their children
How do I get all the sibling nodes and their children?
Can't you traverse up one level starting from the current node, and traverse the parent node (and probably ignoring the current node, aka $currentPage) and child nodes (will probably need some recursive template to get all descendant nodes for each of the siblings)
Hope this helps.
Regards,
/Dirk
Hi Connie,
As Dirk says, you can grab all siblings of a given node by selecting the children of the parent node:
- those variables have access to the individual nodes' children (and grandchildren, ancestors etc.) - just use the standard XPath axes to get to them.
/Chriztian
Well, something is not working right.
This gets every single child node of the parent including grandchildren:
This however returns nothing:
So, there must be something different I have to do for setting the key???
Hi Connie,
To me, it just looks like you've forgot to add current() to get the publicationDate for the current item in the for-each (in the second half of the comparison).
Also: If publicationDate is a standard xmlDate field (e.g. something like: "2011-12-28T12:34:00+0200") there's no need to use extension functions to extract the data you need - example code below:
/Chriztian
I added current() and still get no results. Used your exact code, and still, no results.
Hi Connie
And are you using the new or the old XML schema?
/Jan
New schema.
Hi Connie,
My bad - this is very tricky; in that exact setting, you should not use current() - this works for me, but it's really just using substring() instead of the extension function:
If this still doesn't work, I guess it'd be necessary to have a look at your XML, if possible?
/Chriztian
is working on a reply...