xsl-list
[Top] [All Lists]

Re: [xsl] Dynamic attribute name in predicate

2009-08-06 19:25:18


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
iteration)

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

so $d1 is a single GroupAssigned element

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


<xsl:variable name="d1Rows" select="$allRows[(_at_)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".
or
<xsl:variable name="d1Rows" select="$allRows[(_at_)local-name=$d1]"/>
but that selects all the Row elements with local-name="CRA" (on the
first iteration)

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


David


________________________________________________________________________
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. 
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>