Copied to clipboard

Flag this post as spam?

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


  • [email protected] 30 posts 42 karma points
    Jul 02, 2010 @ 23:30
    r_lamb@hotmail.com
    0

    I can't get my root node now that I'm using 4.5?

    I can do some things, but not others. For example, this does not work:

    <xsl:value-of select="$currentPage/ancestor-or-self::node[last()]/@nodeName"/>

    but this does:

    <xsl:value-of select="$currentPage/@nodeName"/>

    Can anyone tell me why? I've also tried this:

    <xsl:value-of select="$currentPage/parent::node/@nodeName"/>

    This works fine in my older installs. Can anybody tell me why this doesn't work anymore?

  • Jamie Howarth 306 posts 773 karma points c-trib
    Jul 02, 2010 @ 23:44
    Jamie Howarth
    0

    Hi there,

    According to the new schema, nodeName still exists, so your XSLT should work. Check out an example of the new schema here.

    Hope this helps.

    Benjamin

  • [email protected] 30 posts 42 karma points
    Jul 03, 2010 @ 00:48
    r_lamb@hotmail.com
    0

    Thanks for the schema, that will be helpful assuming I ever get this to work:)

  • Jamie Howarth 306 posts 773 karma points c-trib
    Jul 03, 2010 @ 01:16
    Jamie Howarth
    0

    I just took a look at your XSLT - try this:

    <xsl:value-of select="$currentPage/ancestor-or-self::node[position()=last()]/@nodeName"/>

    Best,

    Benjamin

  • [email protected] 30 posts 42 karma points
    Jul 03, 2010 @ 04:29
    r_lamb@hotmail.com
    0

    Thanks for the suggestion, however it's still not working. I don't think I have a syntax issue, I think something is just not working with my 4.5 installation. This is my second attempt at getting it to work. The first was an upgrade, and this one was a fresh install. I don't get why installing 4.5 would cause this not to work? 

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 03, 2010 @ 10:42
    Dirk De Grave
    2

    Hi,

    why not do some simple testing to check whether you actually get to the root node, maybe do some "debugging" such as:

    <xsl:for-each select="currentPage/ancestor-or-self::node">
      <xsl:value-of select="./@nodeName" />
    </xsl:-for-each>

    and check what output you get and work from there.

     

    Hope this helps.

    Regards,

    /Dirk

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Jul 03, 2010 @ 13:55
    Jan Skovgaard
    0

    In addition to Dirk's answer it might be easier to check the output using <xsl:copy-of select="./@nodeName" /> wrapped in a <textarea> element - it gives you all the XML content and you can easily copy/paste in to a proper editor to see what's going on.

    /Jan

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 03, 2010 @ 16:55
    Dirk De Grave
    0

    Or just Xml Dump (http://our.umbraco.org/projects/developer-tools/xml-dump) provided by Chriztian Steinmeier to get the xml

     

    Cheers,

    /Dirk

  • [email protected] 30 posts 42 karma points
    Jul 03, 2010 @ 18:55
    r_lamb@hotmail.com
    0

    Thanks for all the suggestions, I tried them all except for the xmldump. I have a test page here:

    http://umbraco4.brainsparkmedia.com/testing.aspx

    As you can see, there is no output in any of them. The red div borders are the output. I put in a static "value" within the divs just to make sure it was rendering. But none of the xslt suggestions are producing any output except for the first one that is simple doing a <xsl:value-of select="$currentPage/@nodeName"/>. That is the only xslt I can get to work. Something is going on,

    I just don't know how to figure out what it is. Any other suggestions would be appreciated. Thanks!

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jul 03, 2010 @ 19:41
    Lee Kelleher
    1

    Hi r_lamb,

    Just to confirm, are you using Umbraco 4.5? Do you know if you are using the new or old XML schema? (or an easier question, is it a fresh install or an upgrade?)

    If you are using the new schema - which I believe you are, then the XPath expressions that contain 'node' will not work for you - hence you're frustration! :-)

    Try this XSLT snippet, see what you get back.

    <xsl:for-each select="$currentPage/ancestor-or-self::*[@isDoc]">
        <div style="border: solid red 1px">
            value: <xsl:value-of select="@nodeName" />
        </div>
    </xsl:for-each>

    With the new XML schema, you can pretty much replace all the "node" bits with "*[@isDoc]" - but I suggest that very loosely.

    If that still doesn't work, then take a quick look in your /App_Data folder, see if the "umbraco.config" file has any XML inside it. If not, then let us know.

    Cheers, Lee.

  • [email protected] 30 posts 42 karma points
    Jul 03, 2010 @ 19:47
    r_lamb@hotmail.com
    0

    Lee - This is a fresh install of version 4.5 using the new schema. I had guessed that may be my problem. I tried adding the snippet you provided, but it causes errors on save. The error just says "false" when I try and save. Maybe the syntax isn't exactly right? 

    The umbraco.config in the app_data folder does have xml inside. Thanks for you help!

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jul 03, 2010 @ 20:18
    Lee Kelleher
    0

    Hi r_lamb,

    Hmmm... strange, not sure what the error could be.

    Could you try dumping out the XML from the 'testing' page you posted earlier, and pasting a snippet of the XML here?

    <xmp>
        <xsl:copy-of select="$currentPage" />
    </xmp>

    So we can see what we're dealing with... just curious now. :-)

    Thanks, Lee.

  • [email protected] 30 posts 42 karma points
    Jul 05, 2010 @ 17:59
    r_lamb@hotmail.com
    0

    Hi Lee - Not sure exactly what you meant for me to do, but I put your code in my testing page at http://umbraco4.brainsparkmedia.com/testing.aspx and the following xml was generated from your snippet.  Here is the output:

    <Textpage id="1071" parentID="1057" level="2" writerID="0" creatorID="0" nodeType="1046" template="1070" sortOrder="3" createDate="2010-07-03T10:46:43" updateDate="2010-07-05T09:57:42" nodeName="Testing" urlName="testing" writerName="Administrator" creatorName="Administrator" path="-1,1057,1071" isDoc=""><umbracoNaviHide>0</umbracoNaviHide><headerClass>testing</headerClass><bodyText></bodyText></Textpage>

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jul 05, 2010 @ 18:06
    Lee Kelleher
    0

    Hi r_lamb,

    Going back to your original question... how do you get to your root node in v4.5?

    Try the XPath:

    $currentPage/ancestor-or-self::*[@level=1]

    then if you add "/@nodeName" you should get the name of the root node.

    $currentPage/ancestor-or-self::*[@level=1]/@nodeName

    ... and so forth.

     

    I think our answers/replies got a bit side-tracked.  Let us know if there are any misunderstandings.

    Cheers, Lee.

  • [email protected] 30 posts 42 karma points
    Jul 05, 2010 @ 18:33
    r_lamb@hotmail.com
    0

    Lee, your the man! That got me down the right path. I was using this:

    $currentPage/ancestor-or-self::node/@nodeName

    And if I switched it to this instead:

    $currentPage/ancestor-or-self::*/@nodeName

    It worked! I suppose having the @level=1 is needed as well? 

    So, do I need to be using an asterisk instead of "node"? I'm hardly a xslt expert, so it would be helpful if

    someone could help explain the changes I need to make in my xslt. It may not be as simple as looking for node and 

    replacing it with an asterisk, but if it is, that would be great. Thanks a ton for everyone's help!

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Jul 05, 2010 @ 18:47
    Lee Kelleher
    0

    There is a wiki article about how to upgrade your XSLT to the new schema:

    http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/xslt-examples-updated-to-new-schema

    A super-quick overview is that all "node" references can be changed to "*[@isDoc]" ... and "data[@alias='umbracoNaviHide']" can be changed to just "umbracoNaviHide".

    Good luck, and if you get suck with anything specific, let us know.

    Cheers, Lee.

  • [email protected] 30 posts 42 karma points
    Jul 05, 2010 @ 19:00
    r_lamb@hotmail.com
    0

    Yep, that got me going, thanks! 

Please Sign in or register to post replies

Write your reply to:

Draft