"first convert it to a node-set using the msxsl:node-set()"
I am trying to conditionally set the select in a for-each loop using the following (counter simply counts if hte current page has any 'links' below it):
Got my list working now. But, with none of the actual values displaying. I'm guessing this was what you meant by your 'please note'. How can I get round this? Or can I?
I think Chriztian just meant you won't have access to nodes above the ones you are selecting in your variable. Does your for-each need them?
Also - one thing I always seem to have to do when using msxml:node-set is add a /* - for some reason it seems to add an extra element? Try this and see if it works
Tom's right about the "extra" element - this particular for-each will actually only run once, for a virtual wrapper element holding the copied links - usually I have a template for the copied elements and then I do <xsl:apply-templates select="msxml:node-set($variable)" /> instead, and due to some built-in magic my template will be instantiated for every element.
"Now back to you..." :-)
If you just need to do something simple for every link, or if you need to use the (new) position() value for each element, put the code inside the for-each like this, but be specific about the elements (you copied Link elements, so ask for them):
<xsl:for-each select="msxml:node-set($selector)/Link">
<!-- Assuming elements like this: <Link>1057</Link> -->
<a href="umbraco.library:NiceUrl(.)">
<xsl:value-of select="concat('#', position())" />
</a>
</xsl:for-each>
But if you're doing something wee more elaborate, try the template approach:
<xsl:template match="/">
<dl>
<xsl:apply-templates select="msxml:node-set($selector)/Link" />
</dl>
</xsl:template>
<xsl:template match="Link">
<!-- Assuming elements like this: <Link url="http://lego.com/LOST" priority="highest">LEGO LOST: The Pilot (I wish...)</Link> -->
<dt><xsl:value-of select="." /></dt>
<dd class="{@priority}">
<a href="{@url}">
<xsl:value-of select="substring-after(@url, 'http://')" />
</a>
</dd>
</xsl:template>
but i am getting some error . I am getting data from 3 list in single dataview. and when i set variable as mentioned above for first list the other two list are not showing data. if i set the variable as mentioned for 2nd list the 3rd list not showing data can you please help me.
"first convert it to a node-set using the msxsl:node-set()"
I am trying to conditionally set the select in a for-each loop using the following (counter simply counts if hte current page has any 'links' below it):
If I test this in the Umbraco admin area it throws up this error
If I simply put each select statement directly into the variable they both work. It's the select that breaks it.
All suggestions gratefully welcomed. Or, call me an idiot and point me to the relevant documentation
Hi Tony
I'm guessing you should use msxsl:node-set() around $selecter in your for-each like this: msxsl:node-set($selecter)...does this work?
Otherwise I would like to see a snippet of the XML that gets returned to you using a copy-of on the variable.
(Remember to add the correct namespace for the msxsl stuff!)
/Jan
What would bew the correct namespace for that? Everything else I can find suggests
Which I would guess uses
Do you mean something different?
Hi Tony
Yes, that's what I mean. Can't remember the difference (if any) between those two...
But otherwise the namespace for what I mentioned is fairly easy to add, since it's almost identical to the one you posted. It looks like...
xmlns:msxls="urn:schemas-microsoft-com:xslt"
However...more importantly did you get it to work or is it still bugging?
/Jan
Hi Tony,
You need to use copy-of instead of value-of in your selecter variable - and then use msxml:node-set($selecter) in the for-each statement:
Please note: Since the nodes you are processing are now copies, you won't be able to access elements/attributes on parent elements etc.
/Chriztian
Fantastic! Thank you
Got my list working now. But, with none of the actual values displaying. I'm guessing this was what you meant by your 'please note'. How can I get round this? Or can I?
I think Chriztian just meant you won't have access to nodes above the ones you are selecting in your variable. Does your for-each need them?
Also - one thing I always seem to have to do when using msxml:node-set is add a /* - for some reason it seems to add an extra element? Try this and see if it works
And if it does maybe Chriztian can explain :)
Hi Tony (+ Tom),
Tom's right about the "extra" element - this particular for-each will actually only run once, for a virtual wrapper element holding the copied links - usually I have a template for the copied elements and then I do <xsl:apply-templates select="msxml:node-set($variable)" /> instead, and due to some built-in magic my template will be instantiated for every element.
"Now back to you..." :-)
If you just need to do something simple for every link, or if you need to use the (new) position() value for each element, put the code inside the for-each like this, but be specific about the elements (you copied Link elements, so ask for them):
But if you're doing something wee more elaborate, try the template approach:
In either case - have fun :-)
/Chriztian
That's more than sorted me out. Thank you all very much.
hi this was help full to me also.
but i am getting some error . I am getting data from 3 list in single dataview. and when i set variable as mentioned above for first list the other two list are not showing data. if i set the variable as mentioned for 2nd list the 3rd list not showing data can you please help me.
is working on a reply...