Copied to clipboard

Flag this post as spam?

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


  • Robert Valcourt 70 posts 103 karma points
    Oct 13, 2011 @ 05:20
    Robert Valcourt
    0

    XSLT - counting doctype properties - thue/false checked

    I have a doctype that has 20 properties on it... all true/false datatypes. 10 of these properties need to be checked for a true state and counted. So somehow I need to be able to single out or define these 10 properties from all other properties and then build a value of TOTAL clicked true.

    In other words, if 7 of the specific 10 properties have been clicked true, I need to be able to print that value to screen via <vsl:value-of select="$totalTrue"/>

    Can this be done, and if so, can someone please point me in the right direction with a code sample or guide? thx!

  • Rodion Novoselov 694 posts 859 karma points
    Oct 13, 2011 @ 07:28
    Rodion Novoselov
    1

    Hi, first of all it seems to me that you'd better implement your properties with a checkbox list. Since a checkbox list represented by a comma-separated string of the selected options you can count them e.g. like this: 

    <xslt:variable name="selectedOptionCount" select="count(Exslt.ExsltStrings:split($currentPage/yourCheckboxListProperty, ','))"/>
  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Oct 13, 2011 @ 11:49
    Chriztian Steinmeier
    0

    Hi Robert,

    Rodion's suggestion is probably the better solution - but I also know that migrating those 20 properties on a lot of documents will probably never happen, so try this:

    <xsl:value-of select="count($currentPage/*[not(@isDoc)][text() = 1])" />

    of course, if you know something that can make the XPath better, be sure to include that, e.g.: If they're all prefixed with 'use' (useCandyBars, useFreeware, etc.), change the XPath to this:

    <xsl:value-of select="count($currentPage/*[starts-with(name(), 'use')][text() = 1])" /> 

    (if you're inside a loop, you don't need $currentPage, but you may know that already)

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft