I'm going crazy over (what appears to me) a simple for-each loop:
I need a for-each of categories, but only categories that have products underneath them.
I can't check for childnodes within the loop, since I am using position() to but a line break after every third category. (if position() mod 3 = 0 .....)
It looks a llittle bit worse than it actually is - $categoryRoot is of course the parentnode of your categories - /*[@isDoc] takes all Document children of that parentnode; [*[@isDoc]] is the requirement you're after, since it means that the nodes selected by the previous part, must also have child Document nodes.
If your "category" nodes has the Document Type alias "Category", you can make it more readable by using that instead:
How to do Foreach for nodes which have subnodes?
I'm going crazy over (what appears to me) a simple for-each loop:
I need a for-each of categories, but only categories that have products underneath them.
I can't check for childnodes within the loop, since I am using position() to but a line break after every third category. (if position() mod 3 = 0 .....)
Anybody?
Hi Jan,
You should put that requirement in the select attribute of your for-each:
It looks a llittle bit worse than it actually is - $categoryRoot is of course the parentnode of your categories - /*[@isDoc] takes all Document children of that parentnode; [*[@isDoc]] is the requirement you're after, since it means that the nodes selected by the previous part, must also have child Document nodes.
If your "category" nodes has the Document Type alias "Category", you can make it more readable by using that instead:
- much better, right?
/Chriztian
is working on a reply...