Copied to clipboard

Flag this post as spam?

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


  • Connie DeCinko 931 posts 1160 karma points
    Jul 28, 2010 @ 23:40
    Connie DeCinko
    0

    ancestor-or-self with new schema

    What is the proper way to refer to ancestor-or-self with the new 4.5 schema?  The old version is:

    $currentPage/ancestor-or-self::node/data [@alias = 'metaKeywords']
  • criticalmaas 10 posts 28 karma points
    Jul 28, 2010 @ 23:44
    criticalmaas
    0

    I think it would be:

    $currentPage/ancestor-or-self::metaKeywords
  • Connie DeCinko 931 posts 1160 karma points
    Jul 29, 2010 @ 00:02
    Connie DeCinko
    0

    Not getting any results.

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Jul 29, 2010 @ 00:06
    Chriztian Steinmeier
    1

    Hi Connie,

    If you know the nodeTypeAlias (e.g. 'Textpage') of your document type, you should use that:

    $currentPage/ancestor-or-self::Textpage/metaKeywords

    Otherwise, use the more generic:

    $currentPage/ancestor-or-self::*[@isDoc]/metaKeywords

    /Chriztian

  • Connie DeCinko 931 posts 1160 karma points
    Jul 29, 2010 @ 00:31
    Connie DeCinko
    0

    All of the above should work, but are not.  Gotta be missing something.

    <xsl:attribute name="content">
    <xsl:value-of select="$currentPage/ancestor-or-self::* /metaKeywords" disable-output-escaping="yes"/>
    </xsl:attribute>
  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Jul 29, 2010 @ 00:49
    Chriztian Steinmeier
    0

    Hi Connie,

    This could be related to a question I just wrote a loooong answer for... try this:

    <xsl:attribute name="content">
        <xsl:value-of select="$currentPage/ancestor-or-self::*[metaKeywords[normalize-space()]][1]/metaKeywords" />
    </xsl:attribute>

    This will take the metaKeywords property on the closest ancestor that actually has a value set for it. 

    /Chriztian 

  • Connie DeCinko 931 posts 1160 karma points
    Jul 29, 2010 @ 00:57
    Connie DeCinko
    0

    That works!  When you have time, it would be nice to know why.

    Thanks!

     

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Jul 29, 2010 @ 00:59
    Chriztian Steinmeier
    0

    Great - that's good!

    The answer I mentioned is right here: http://our.umbraco.org/forum/developers/xslt/10934-XSLT-fails-after-publish?p=0#comment40836

    /Chriztian

  • criticalmaas 10 posts 28 karma points
    Jul 29, 2010 @ 01:00
    criticalmaas
    0

    or you might want try a text() !='' test as in:

    <xsl:attribute name="content">
      <xsl:value-of select="$currentPage/ancestor-or-self::metaKeywords[text() !='']"/>
    </xsl:attribute>

     

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies