Copied to clipboard

Flag this post as spam?

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


  • maanehunden 61 posts 105 karma points
    Dec 07, 2010 @ 22:49
    maanehunden
    0

    Umbraco 4.5.2 - returns emty string when quering @nodeTypeAlias

    I've puzzled by this error i've spend a couple of days trying to figure this one out. Some how i can't get my xslt to return a nodes  @nodeTypeAlias. 
    I've created my doctype as i allays do,.. http://img811.imageshack.us/i/screenshot004r.jpg/ her's my content tree http://img98.imageshack.us/i/screenshot005g0.jpg/ ;

    and the code,..

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet 
      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" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" 
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">

    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>
    <xsl:variable name="home" select="umbraco.library:GetXmlAll()/node[@nodeTypeAlias ='ffHome']"></xsl:variable>
    <xsl:variable name="home1" select="umbraco.library:GetXmlAll()/node[@nodeTypeAlias ='RunwayHomepage']"/>
    <xsl:variable name="levelOneNode" select="$currentPage/ancestor-or-self::node[@nodeTypeAlias ='ffHome']"/>
        
    <xsl:template match="/">

    <!-- start writing XSLT -->
    <div style="border:solid 1px red; color:white;">
    [<xsl:value-of select="$currentPage/@nodeTypeAlias "/>]
    [<xsl:value-of select="$home/
    @nodeTypeAlias"/>]
    [<xsl:value-of select="$home1/@nodeTypeAlias"/>]

    </div>

    </xsl:template>

    </xsl:stylesheet>

    Some how they all came out empty,.. ?? Just doesn't make any sense to me ,..
    any suggestions..

  • Kim Andersen 1447 posts 2196 karma points MVP
    Dec 07, 2010 @ 23:13
    Kim Andersen
    1

    In the new XML schema the nodeTypeAlias is now the name of the nodes. Means that you code must be changed to this:

    <xsl:variable name="home" select="umbraco.library:GetXmlAll()/ffHome[@isDoc]"></xsl:variable>
    <xsl:variable name="home1" select="umbraco.library:GetXmlAll()/
    RunwayHomepage[@isDoc]"/>
    <xsl:variable name="levelOneNode" select="$currentPage/ancestor-or-self::ffHome[@isDoc]"/>

    ....

    <div style="border:solid 1px red; color:white;">
    [<xsl:value-of select="$currentPage/name() "/>]
    [<xsl:value-of select="$home
    "/>]
    [<xsl:value-of select="$home1"/>]
    </div>

    I'm pretty sure this will work for you.

    /Kim A

  • maanehunden 61 posts 105 karma points
    Dec 09, 2010 @ 21:47
    maanehunden
    0

    brilliant,. thanks Kim, a bit disappointed thou about them changing the XML schema that way,.. but hay ,.. more fun to be learned ,.. I've found this article about this subject ,.. i don't know how it eluded me but her it is http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/no-more-@nodetypealias,.. and http://our.umbraco.org/wiki/reference/xslt/45-xml-schema 
    http://our.umbraco.org/wiki/reference/xslt/recursive-menu-umbraco-45

    Hope it can help some one,.. 

    Btw,.. could be fun to see more examples,.. 
     

  • Rich Green 2246 posts 4008 karma points
    Dec 09, 2010 @ 21:49
    Rich Green
    0

    Hi,

    If you have 4.5.2 install you can see more examples by selecting a template when you create a new xslt file.

    Rich 

  • Kim Andersen 1447 posts 2196 karma points MVP
    Dec 09, 2010 @ 22:02
    Kim Andersen
    0

    You are welcome maanehunden. I think the new XML schema is great. It rocks. I love it :)

    But in the beginning it can maybe be a little confusing and of course it takes some time learning a new schema. A good way of learning how to work with the new schema, is to see how the XML is build. You can do this in a couple of ways. The old school way of doing it is printing the XML out in a textarea like this:

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

    This will give you the XML of the current page. You can do this with all the stuff that you want, like e.g. the result of an extension like this:

    <textarea>
    <xsl:copy-of select="umbraco.library:GetMedia($currentPage/mediaPicker,0)" />
    </textarea>

    Another approach is to use Chriztian Steinmeir's package called XML Dump. You can find it right here.

    /Kim A

  • maanehunden 61 posts 105 karma points
    Dec 09, 2010 @ 23:10
    maanehunden
    0

    thx .. Rich and Kim A, some good tips there,. i especially like the textarea "hack",.. i am going to be using that a'lot (c:

Please Sign in or register to post replies

Write your reply to:

Draft