Copied to clipboard

Flag this post as spam?

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


  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jan 05, 2009 @ 11:26
    Ismail Mayat
    0

    Random nodes

    Guys,

    I am trying to pick a number of random nodes from a collection of nodes and its not quite working. Here is what i have:

    1. I am selecting all children and sub children of 2 nodes at level2 ie

    [code]

    [/code]

    this gives me around 60 nodes.

    2. I have extended the xslt with some c# to give me a number (4 or 6) of random numbers the seed for the generator is the count of step 1 so i am getting back 4 or 6 random numbers 1 - 60.

    3. Im my code i am trying to select the nodes i got in 1 using the following code

    [code]

    [/code]

    the issue is that becuase the selected nodes are nested the position of each element is not linear so sometimes i get no nodes. The other issue is if my itemNo is for example 10 then i get more than one node back becuase 10 is position of 3 nodes in more than one section of the tree of sub nodes. Is there a way of linearising the selected nodes so that when i do $nodes//node[$itemNo] i get back the actual node.

    Hope this makes sense.

    Regards

    Ismail

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Jan 05, 2009 @ 13:10
    Ismail Mayat
    0

    Guys,

    I have sorted this with a little help from Soren Sprogge. I updated the xslt to create a new node set which i then set to a variable then used msxsl-nodeset on that fragement. The creation of the new nodeset gave me linear position values:

    [code]





    msxsl:node-set($actualNodes)//node"/>




    [/code]

    Regards

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft