Copied to clipboard

Flag this post as spam?

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


  • Roger Swearingen 28 posts 49 karma points
    Oct 28, 2010 @ 00:04
    Roger Swearingen
    0

    4.5.2 Boolean Node ID Test

    I am having trouble getting the following snippet converted to the new schema.  It worked great in 4.0, but I just noticed that it does not work on 4.5.2 (I thought I was done converting when i noticed this..) :

     <xsl:if test="boolean(.//node[@id = $target])">{selected:<xsl:value-of select="position()-1"/>}</xsl:if>

    FYI - target = $currentPage/@id

     

    It is definitely failing at the <xsl:if test="boolean(.//node[@id = $target])"> part.

     

    I have tried replacing everything I could think of, but I am stuck. Anything I do returns nothing. Any ideas?

     

    Thanks in advance.

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Oct 28, 2010 @ 00:56
    Aaron Powell
    0

    If you're using the new XML schema then there isn't any <node /> elements any more, the alias of the document type is used.

    If you know the document type that it should be you can do this:

    <xsl:if test="boolean(.//myDocType[@id = $target])">...

    If you don't know the alias of the document type (or you just want to match any document types) use this:

    <xsl:if test="boolean(.//*[@id = $target && @isDoc])">...

    Using * will match any document type, and the @idDoc is the attribute placed on a document type level XML element

    (Note: The 'and' condition may not be 100% right)

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Oct 28, 2010 @ 01:38
    Chriztian Steinmeier
    0

    Hi Jeff,

    This will do it:

    <xsl:if test=".//*[@isDoc]/@id = $target">{selected: <xsl:value-of select="position() - 1" />}</xsl:if>

    As Aaron (slace) says, it's best to use the Doctype's alias if you know it.

    (You don't need the boolean() - that's actually done implicitly in a test attribute)

    /Chriztian

  • Roger Swearingen 28 posts 49 karma points
    Oct 28, 2010 @ 01:57
    Roger Swearingen
    0

    Ahh.  I knew about replacing the 'node' with '*[@isDoc]", but my syntax was way off.  I was trying to use an 'and' statement.  There are multiple doc types, so * should be fine.

     

    Thanks to both of you.

     

    Chriztian this is the 2nd time in a month that you have saved me.  I couldn't get back into the other post to thank you (kept getting server errors), but you rock!

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    Oct 28, 2010 @ 10:21
    Chriztian Steinmeier
    0

    No worries Jeff - I remember that other one - if you really want to close it though, you can strip everything but the ID from the URL to a post, and access it that way.

    /Chriztian

  • 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