I have installed the CWS and it has a list of news that is rendered using xslt.
Now I want to load an image beside each news item. However the entry that hold the url for the image is waaaay down the xml tree:
blah-blah
/media/3226/j0438865.jpg
0
I get the output by using , however if I try to add filters to that select I don't get what I expect. I've tried select="data [@alias='umbracoUrlName]//data [@alias='umbracoUrlAlias']//data [@alias='umbracoUrlRedirect']"... :-)
Is there some way on xslt I can seek down the nodes to find a specific node? I want to find the crop-node with the attribute name set to "newsListPhoto"
I just got it to work now. It seems the "current" data node didn't hold the xml somehow. I solved it by first adding a variable like this:
I then added a new variable like this:
Finally I test if the $imageSrc is empty or not, and if it has a value, I make an image.
Thanks for helping Dirk, even though you didn't point out the final solution, your guidance made me more certain I was on the right track... not always sure of what I'm doing when it comes to this xslt-programming stuff :-)
Hmm... I'm going out of my mind here. Seems that xpath throws my markup out of order. I can't get this to work properly, and these things are pretty hard to debug :-(
I don't know why, but by moving some of the html markup (the div's), it started to work... magic... Doesn't make sense, but it works, so I won't ever tough it again ;-)
OK as a tip Skaue your XSLT is working fine but as a suggestion you could drop
[code][/code]
and update your imageSrc variable to this
[code][/code]
I recommend also changing the xsl:choose for your imageSrc variable to an xsl:if if you are not going to use the xsl:otherwise for ouputting markup for when you dont find an imagecrop.
All of these suggestions are matter of personal coding taste as there are 101 ways to do the same thing, but all the same I hope it helps you out and unserstand xpath/xslt more.
Traversing down the node-tree
I have installed the CWS and it has a list of news that is rendered using xslt.
Now I want to load an image beside each news item. However the entry that hold the url for the image is waaaay down the xml tree:
blah-blah
/media/3226/j0438865.jpg
0
I get the output by using , however if I try to add filters to that select I don't get what I expect. I've tried select="data [@alias='umbracoUrlName]//data [@alias='umbracoUrlAlias']//data [@alias='umbracoUrlRedirect']"... :-)
Is there some way on xslt I can seek down the nodes to find a specific node? I want to find the crop-node with the attribute name set to "newsListPhoto"
Hi,
[code][/code] will get the entire node fragment
[code][/code]
But as this is xml you won't get nice output on screen.
If you want to get to the crop node that has name attribute set to 'newsListPhoto', use:
[code][/code]
Again, first part selects the
Thanks for helping out, Dirk. I didn't get anything out from that selection, unfortunately.
What exactly does the dot-dash (./) do?
Is there any way to debug this without downloading everything and setting up IIS locally. I have this running on a web hotel.
Hi skaue,
I don't exactly know how the xslt looks like right now, that is why I'm using the ./data construct.
For example, in a for-each loop
[code][/code]
the . refers to the current node being processed. It could have been omitted, but I tend to write those for clarity.
Can you show us what xslt you're having now and where you'd like to have the pic inserted?
Regards,
/Dirk
I just got it to work now. It seems the "current" data node didn't hold the xml somehow. I solved it by first adding a variable like this:
I then added a new variable like this:
Finally I test if the $imageSrc is empty or not, and if it has a value, I make an image.
Thanks for helping Dirk, even though you didn't point out the final solution, your guidance made me more certain I was on the right track... not always sure of what I'm doing when it comes to this xslt-programming stuff :-)
;-)
Hmm... I'm going out of my mind here. Seems that xpath throws my markup out of order. I can't get this to work properly, and these things are pretty hard to debug :-(
Here's my complete xslt:
[code]
]>
<>
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="msxml umbraco.library">
[/code]
I don't know why, but by moving some of the html markup (the div's), it started to work... magic... Doesn't make sense, but it works, so I won't ever tough it again ;-)
OK as a tip Skaue your XSLT is working fine but as a suggestion you could drop
[code][/code]
and update your imageSrc variable to this
[code][/code]
I recommend also changing the xsl:choose for your imageSrc variable to an xsl:if if you are not going to use the xsl:otherwise for ouputting markup for when you dont find an imagecrop.
All of these suggestions are matter of personal coding taste as there are 101 ways to do the same thing, but all the same I hope it helps you out and unserstand xpath/xslt more.
Warren :)
"Error parsing XSLT file: \xslt\forum-commentsList.xslt"</span>
bug?
is working on a reply...