I'm using the treemultipicker for a features list.
If an included node is removed (deleted/unpublished) from the site, the features list breaks, so I am checking to make sure all the nodes exist before trying to access the properties in xslt and output, like so...
This code doesn't work, obviously i could just check node exists before final output of the items, but i want to count and group my node list etc before any output, so...
A) Can i not use a for-each inside the variable or...
A: Yes you can - but there's a small caveat: You need to use the copy-of instruction to grab the items for the variable, and even then, you'll need to use an extension function to be able to XPath your way through the nodes in the variable - build your variable this way instead:
Now, the relItems variable holds a reference to the nodes that actually exist in the XML, and you can do your "normal" stuf (i.e. use for-each or apply-templates, with or without sorting):
<xsl:for-each select="$relItems/node">
<p>
I was here...
</p>
</xsl:for-each>
And remember in using these items if you want to get the original node (with position in the tree, etc) you need to GetXmlNodeById() to get the original node not the copy-of.
For-each inside variable
Hi all
I'm using the treemultipicker for a features list.
If an included node is removed (deleted/unpublished) from the site, the features list breaks, so I am checking to make sure all the nodes exist before trying to access the properties in xslt and output, like so...
This code doesn't work, obviously i could just check node exists before final output of the items, but i want to count and group my node list etc before any output, so...
A) Can i not use a for-each inside the variable or...
B) What is wrong with the code above?
C) Any better solution/s?
Hi Josh,
A: Yes you can - but there's a small caveat: You need to use the copy-of instruction to grab the items for the variable, and even then, you'll need to use an extension function to be able to XPath your way through the nodes in the variable - build your variable this way instead:
Now, the relItems variable holds a reference to the nodes that actually exist in the XML, and you can do your "normal" stuf (i.e. use for-each or apply-templates, with or without sorting):
Hope it answers B & C too in a way...
/Chriztian
Whoops - missed a thing in the copy-of selection:
/Chriztian
Thanks Chriztian!
Alright just so the thread ends with a clean solution:
And remember in using these items if you want to get the original node (with position in the tree, etc) you need to GetXmlNodeById() to get the original node not the copy-of.
JR
is working on a reply...