Copied to clipboard

Flag this post as spam?

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


  • Powellze 38 posts 73 karma points
    Oct 22, 2010 @ 14:16
    Powellze
    0

    New XSLT Schema - driving me up the wall!

    Hi Everyone, It's been a while since I have had to post but this one really is because I am struggling to get my head around the new XSLT Schema.

     

    I am running my site in XSLT Legacy mode via the setting in /config/umbracoSettings.config.

     

    1) Does this mean that the new schema will not work at all?

     

    2) I have seen some nice code examples for doing simple things but when I try to test these I don't seem to get a result that is expected for example:

    current() [string(./umbracoNaviHide) != '1']/@nodeName
    or
    current() [not(umbracoNaviHide) = 1]/@nodeName

    - both will happily return an node that has UmbracoNaviHide turned on which is not what I would expect. The old way of doing this was to do, this would work and stop the navigation item not being shown:

    current()/data [@alias='umbracoNaviHide' != '1']

     

    3) Whats the best way to replace:

    <xsl:when test="current()[@nodeTypeAlias='BS_Folder']/@id = $currentPage/parent::node/@id">

    I would expect something on the lines of this below?

    <xsl:when test="current() [self::not(BS_Folder)]/@id = $currentPage/parent::*/@id">

     

    Thanks for the help.

    Tim

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Oct 22, 2010 @ 15:25
    Jan Skovgaard
    0

    Hi Tim

    1) If you're running the legacy schema you should use the old way of fetching values off course? So yes, legacy won't work with the new syntax.

    2) I guess you should be using the old way of doing it, since you're using the legacy schema

    3) You are pretty close. I think that it will actually work, but it's a good idea to check if it's a document you're fetching from. So it should look like this

    <xsl:when test="current() [self::not(BS_Folder)]/@id = $currentPage/parent::*[@IsDoc]/@id">

    Hope this helps a bit? :-)

    /Jan

  • Powellze 38 posts 73 karma points
    Oct 22, 2010 @ 16:51
    Powellze
    0

    Hi Jan,

    Thanks for explaining a few things.

    I have turned off the legacy schema, but I am still having trouble making sense of the new way of writing XSLT. I have used the same tests above as in #2 above and I am still not being able to work a true/false statement from:

    <xsl:value-of select="current() [not(umbracoNaviHide) = 1]/@nodeName" />

    I know that the above statement will return a node name, but surely the above should only return the node name if the property is 'false' as in not 1 like above?

    Once I have a grasp of the little bits I will be able to battle through as my XSLT library isn't too bad, just that I am having a few stumbling blocks with the code not returning what I would expect :(

     

    Thanks,

    Tim

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Oct 22, 2010 @ 16:58
    Tom Fulton
    0

    I might be missing something as I've never used the not() function, but wouldn't it be:  not(umbracoNaviHide = 1) or just not(umbracoNaviHide)?  

    I've always used string(umbracoNaviHide) != '1'

     

  • Powellze 38 posts 73 karma points
    Oct 22, 2010 @ 17:08
    Powellze
    0

    Hi Tom, What you are saying makes sense. I have tried to evaulate this but still It is selecting the node which has umbracoNaviHide set to 1. which still makes me think I haven't quite got the syntax/implementation right. I think I am going to hit the drawing board now and start to write a load of expressions to work out what I should expect. At the moment what I write and what I get back are completely different!

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Oct 23, 2010 @ 19:32
    Chriztian Steinmeier
    0

    Hi Powellze,

    With regards to umbracoNaviHide, this is how it's used with the not() function to look:

    <xsl:value-of select="current()[not(umbracoNaviHide = 1)]/@nodeName" />

     

    As for #3: The "New Schema" translation reads:

    <xsl:when test="current()[self::BS_Folder]/@id = $currentPage/../@id">

    - though, I'm hard pressed coming up with a scenario where current() would at all be needed in the beginning of an expression, so you should also be able to say:

    <xsl:when test="self::BS_Folder[@id = $currentPage/../@id]">

    /Chriztian

  • Powellze 38 posts 73 karma points
    Oct 25, 2010 @ 17:14
    Powellze
    0

    Hi Chriztian,

     

    I want to thank you and everyone else for their time. I have been able to get my navigation working and have gone back and I am now updating a lot of the old XSLT. The new schema is very nice once you get your head around it. I like the use of the axes to perform the conditions.

    One of the issues I was having was that when you switch to the new schema it looks as though you need to republish the entire site so that the DB is updated?

     

    Thanks Tim

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Oct 25, 2010 @ 20:26
    Chriztian Steinmeier
    1

    Hi Tim,

    You're welcome!

    Republishing makes perfect sense - you're changing how every single node in the tree "looks", so the disk version ("umbraco.config") as well as the in-memory version needs to be rebuilt.

    /Chriztian 

Please Sign in or register to post replies

Write your reply to:

Draft