Re: [xsl] Dynamic attribute name in predicate

Subject: Re: [xsl] Dynamic attribute name in predicate
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 7 Aug 2009 00:24:46 +0100
you don't say what result you expect or what your source looks like so
its a bit hard to say what code you should have, but I can point you at
the syntax errors in the non working bits.

<xsl:variable name="allRows" select="/dsQueryResponse/Rows/Row"/>

so $allRows is a set of Row elements.

<xsl:for-each select="msxsl:node-set($D1)/GroupAssigned">

so at each of the three iterations, . will be a GroupAssigned element
(which has content but no attributes)

<td><xsl:value-of select="." /></td>

so that returns the string value of the element (CRA on the first

<xsl:variable name="d1" select="."/>

so $d1 is a single GroupAssigned element

<xsl:variable name="d1Rows" select="$allRows[@GroupAssigned=$d1]"/>
so on the first iteration, d1 rows is thus the set of Row elements with
which what I guessed you wanted. You don't say how you use this

<xsl:variable name="d1Rows" select="$allRows[@local-name()=$d1]"/>
that's a syntax error. You can either have

<xsl:variable name="d1Rows" select="$allRows[local-name()=$d1]"/>
which selects all the elements with local name equal to $d1, but you
don't want that as all the elements have local name "Row".
<xsl:variable name="d1Rows" select="$allRows[@local-name=$d1]"/>
but that selects all the Row elements with local-name="CRA" (on the
first iteration)

<xsl:variable name="d1Rows" select="$allRows[@GroupAssigned=.]"/>
that selects all Row elements whose GroupAssigned attribute is equal to
their content, eg <Row GroupAssigned="foo">foo</Row> and would select
same elements on each iteration as the expression doesn't depend on tehe
loop context.


The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 

Current Thread