Copied to clipboard

Flag this post as spam?

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


  • syn-rg 282 posts 425 karma points
    Dec 28, 2012 @ 03:05
    syn-rg
    0

    XSLT list by latest versionNumber value

    I'm creating a download macro and I'm listing items from the media section by selecting the media folder they are uploaded to.

    I've created a media type Asset, which has potential child nodes, Asset Version.

    I can create as many Asset Version's as I like, but I only want the latest Asset Version displayed in my download macro. I've added a label to my Asset Version, versionNumber, that adds a number value created within the same Asset.

    e.g. Asset
    Asset Version - versionNumber = 1
    Asset Version - versionNumber = 2
    Asset Version  - versionNumber = 3

    Currently this lists only Asset Version with versionNumber = 1:

    <xsl:for-each select="$files/Asset/AssetVersion[@nodeTypeAlias = 'AssetVersion' and versionNumber= '1']">
      <xsl:sort select="./versionNumber" data-type="number" order="descending"/>
      <xsl:call-template name="Documents" />
    </xsl:for-each>

    I only want the latest Asset Version to display in my list, and only that version.

    Can anybody help?

    Cheers JV

  • syn-rg 282 posts 425 karma points
    Dec 28, 2012 @ 06:26
    syn-rg
    0

    My download macro can list multiple Asset's, but should only display one AssetVersion for each.

    e.g. Download macro

    • Asset 1
      • Asset 1 - Asset Version - versionNumber = 3
    • Asset 2
      • Asset 2 - Asset Version - versionNumber = 1
    • Asset 3
      • Asset 3 - Asset Version - versionNumber = 6
  • syn-rg 282 posts 425 karma points
    Dec 28, 2012 @ 06:49
    syn-rg
    100

    Solved it:

    <xsl:for-eachselect="$files/Asset"><!-- output here the Asset number /id --><xsl:for-eachselect="AssetVersion[@nodeTypeAlias = 'AssetVersion']"><xsl:sortselect="versionNumber"data-type="number"order="descending"/><xsl:iftest="position()=1"><xsl:call-templatename="Documents"/></xsl:if></xsl:for-each></xsl:for-each>
Please Sign in or register to post replies

Write your reply to:

Draft