Copied to clipboard

Flag this post as spam?

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


  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Aug 27, 2009 @ 16:14
    Sebastiaan Janssen
    0

    Get all documents of a document type with criteria

    I'm having a bit of trouble, hope you guys can spot my error. I am trying to loop through all of the documents with a documenttype of "book". I want to see only the books that are set as tip. The tip checkbox is called "isTip". So I thought I'd try this:

    <xsl:for-each select="umbraco.library:GetXmlAll()//node [@nodeTypeAlias='Book']/node [string(data [@alias='isTip']) = 1]">
     <xsl:value-of select="./@nodeName"/> - <xsl:value-of select="string(data [@alias='isTip'])" />
     <br />
    </xsl:for-each>

    This returns no result :-(
    However, when I leave off the "isTip" criteria in the for-each, I get a nice list of books and 1's and 0's for the tips checkboxes:

    <xsl:for-each select="umbraco.library:GetXmlAll()//node [@nodeTypeAlias='Panorama']">
     <xsl:value-of select="./@nodeName"/> - <xsl:value-of select="string(data [@alias='isTip'])" />
     <br />
    </xsl:for-each>

    So, what am I doing wrong in that extra criterion?

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Aug 27, 2009 @ 16:15
    Sebastiaan Janssen
    0

    Grrr, no "edit" button. The 'Panorama' in the second sample should read 'Book' of course.

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Aug 27, 2009 @ 16:24
    Peter Dijksterhuis
    0

    I think this should do the trick:

    <xsl:for-each select="umbraco.library:GetXmlAll()//node [@nodeTypeAlias='Book']/data [@alias='isTip'] = '1'">

    HTH,

    Peter

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Aug 27, 2009 @ 16:50
    Sebastiaan Janssen
    0

    Yeah, I tried leaving off the "node" part, but the XSLT parser didn't like that all too much.

  • Daniel Lindstrom 454 posts 271 karma points
    Aug 27, 2009 @ 16:57
    Daniel Lindstrom
    0

    Maybe the relevant difference in Peters code is the data type in the second condition?

    In your original code you are converting isTip to string, but the comparing it to an integer (without ').

    Yours

    [string(data [@alias='isTip']) = 1]

    Peters

    [string(data [@alias='isTip']) = '1']
  • Peter Dijksterhuis 1442 posts 1722 karma points
    Aug 27, 2009 @ 16:58
    Peter Dijksterhuis
    0

    What about this:

    <xsl:for-each select="umbraco.library:GetXmlAll()//node [(@nodeTypeAlias = 'Book') and (data [@alias='isTip'] = '1')]">

     

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Aug 27, 2009 @ 17:04
    Peter Dijksterhuis
    101

    Hm, last one was close, this should work:

    <xsl:for-each select="umbraco.library:GetXmlAll()//node[@nodeTypeAlias = 'Book' and string(data[@alias = 'isTip']) = '1']">

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Aug 27, 2009 @ 17:13
    Sebastiaan Janssen
    0

    Thanks Daniel, I did correct this :-)

    It's just not working, second suggestion doesn't work either Peter. 

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Aug 27, 2009 @ 17:14
    Sebastiaan Janssen
    0

    Aah, thanks Peter! I get it now, the expression was not properly surrounded by brackets. Cool, learn something new every day!

Please Sign in or register to post replies

Write your reply to:

Draft