Re: node-set() and dynamic variable setting Options
chimnit
Posted: Thursday, February 28, 2008 12:30:43 AM
Rank: Devotee

Joined: 10/25/2007
Posts: 59
Hi everybody,

I'm creating a filter that needs to join diffenrent filtering results. But I have a problem assigning variables in XSLT, which are node-sets.

Her is my code:
Code:
    <!-- Filters the source for Categories -->
    <xsl:variable name="categoryFilteredSource">
      <xsl:if test="$FilterCategory != ''">
        <xsl:value-of select="$source[umbraco.library:LastIndexOf(data [@alias='Categories'], $FilterCategory) != '-1']"/>
      </xsl:if>
    </xsl:variable>

    kat: <xsl:value-of select="msxml:node-set($categoryFilteredSource)"/><br/>

    <xsl:value-of select="count($source[umbraco.library:LastIndexOf(data [@alias='Categories'], $FilterCategory) != '-1'])"/> <!-- Does return the correct value -->
    katCount: <xsl:value-of select="count(msxml:node-set($categoryFilteredSource))"/><br/> <!-- Does not return the correct value. Always returns 1 -->
   
    <xsl:for-each select="msxml:node-set($categoryFilteredSource)">
      <xsl:value-of select="./@nodeName"/>
    </xsl:for-each> 


So what happens is this: When assigning the $categoryFilteredSource I only want it to contain a value if the $FilterCategory variable is set. This does seem to work, because hen printing the contents of the $categoryFilteredSource variable it doesn't seem to have any contents, when $FilterCategory is '' and does have contents when $FilterCategory is set.

The wierd part is that regardless if the $FilterCategory varibel is set or not, the count of the $categoryFilteredSource variable is 1.
And it is not possible to iterate over the $categoryFilteredSource contents in any situation.

Can anybody help as I'm goig nuts over this issue...

Thanks a lot in advance :o)

/Kim
imayat12
Posted: Thursday, February 28, 2008 8:38:17 AM

Rank: Addict

Joined: 7/19/2006
Posts: 649
Location: Preston, UK
Kim,

Change your code:

Code:
    <xsl:value-of select="$source[umbraco.library:LastIndexOf(data [@alias='Categories'], $FilterCategory) != '-1']"/> 


to

Code:
    <xsl:copy-of select="$source[umbraco.library:LastIndexOf(data [@alias='Categories'], $FilterCategory) != '-1']"/> 


then when you do your node-set() you will get some nodes. I did post something on the forum about this but cant find it :no:

Regards

Ismail

Level 2 certified. If it aint broke dont fix.
chimnit
Posted: Friday, February 29, 2008 11:36:54 AM
Rank: Devotee

Joined: 10/25/2007
Posts: 59
Hi Ismail

Thanks a lot for your reply. I have tried it, but I still seem to have the same issue. The count of $categoryFilteredSource is still 1 regardless of having content or not and it still doesn't seem to work, when I dynamkically assign the variable with a node-set().

Do you have any other suggestions???

Thanks in advance :o)

Kim
chimnit
Posted: Monday, March 03, 2008 5:18:44 PM
Rank: Devotee

Joined: 10/25/2007
Posts: 59
Hi Ismail

I just wanted to get back to your solution model. After having tested once again, I have found that the copy-of returns more nodes than I found before. They don't seem to show up when runnning a count() on the variable they are passed into, but the contents of the variable are different than when running a value-of select.

Thank you for your help.

Kin regards

Kim
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.