RandomItemsItem.xsl

Requires: math.random.xsl

This XSLT is generic enough to work with many of these samples. Including the CamlQueryDataProvider since it uses Items/Item by default. If that is changed, then you'll need to do custom XSLT.

For performance sake you will want to change this line to point to your own server:

Until http://sharepointpowertoys.com/Style%20Library/XSL%20Style%20Sheets/math.random.xsl

<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:math="http://exslt.org/math">
  <xsl:import href="http://sharepointpowertoys.com/Style%20Library/XSL%20Style%20Sheets/math.random.xsl" />
  <xsl:output method="html" indent="no" />
  <!-- RandomItemsItem by David Walker - www.davidlwalker.com and www.sharepointpowertoys.com -->
  <xsl:variable name="parent" select="/items/item" />
  <xsl:variable name="count" select="count($parent)+1" />
  <xsl:variable name="random" select="math:random(1, $count, 1)"/>
  <xsl:template match="/">
    <xsl:for-each select="$parent">
      <xsl:if test="position()=$random">
        <xsl:value-of select="." />
      </xsl:if>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

RandomItemsItem.xsl

Last edited Jun 28, 2008 at 4:37 AM by davidlwalker, version 6

Comments

No comments yet.