Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • skaue 43 posts 44 karma points
    May 06, 2009 @ 17:51
    skaue
    0

    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']"... :-)

  • skaue 43 posts 44 karma points
    May 06, 2009 @ 19:54
    skaue
    0

    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"

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    May 06, 2009 @ 21:15
    Dirk De Grave
    0

    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

  • skaue 43 posts 44 karma points
    May 06, 2009 @ 22:26
    skaue
    0

    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.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    May 06, 2009 @ 22:55
    Dirk De Grave
    0

    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


  • skaue 43 posts 44 karma points
    May 06, 2009 @ 23:03
    skaue
    0

    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 :-)

    ;-)

  • skaue 43 posts 44 karma points
    May 07, 2009 @ 11:06
    skaue
    0

    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]

  • skaue 43 posts 44 karma points
    May 07, 2009 @ 12:17
    skaue
    0

    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 ;-)

  • Warren Buckley 2106 posts 4836 karma points MVP ∞ admin hq c-trib
    May 08, 2009 @ 16:04
    Warren Buckley
    0

    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 :)

  • skaue 43 posts 44 karma points
    Jul 01, 2009 @ 10:00
    skaue
    0

    "Error parsing XSLT file: \xslt\forum-commentsList.xslt"</span>

    bug?

Please Sign in or register to post replies

Write your reply to:

Draft