RE: [xsl] Dynamically creating XPath expressions Help required

Subject: RE: [xsl] Dynamically creating XPath expressions Help required
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 2 Apr 2004 08:44:08 +0100
The value of your variable is a string starting with the characters "../",
this string will never be equal to 1. You've missed out the crucial stage of
telling the system to treat the string as an XPath expression and evaluate
it. For this you need the xx:evaluate() extension function available in some
processors such as Saxon and Xalan.

Michael Kay 

> -----Original Message-----
> From: cheburashka@xxxxxxxxxx [mailto:cheburashka@xxxxxxxxxx] 
> Sent: 02 April 2004 02:15
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Dynamically creating XPath expressions Help required 
> 
> Hi my name is adam, I got your email address from the google 
> search. I hpoe you do not mind me contacting you directly.But 
> I need help with some xslt.
> 
> I am constructing a table, Each GridBody0 - GridBody n
> node set represents a single row of the table.Each Gridbody 
> tag included a number of Col0 - Col n tags
> these represent each cell of the row.
> 
> The problem is that each cell that is rendered must be 
> conditionally formatted.Tags that need to be formatted are
> include within the gridcolors section of the xml document.
> 
>   <Grid0Row0Col3LimeGreen>1</Grid0Row0Col3LimeGreen>
> 
>  The idea is to use a for-each loop to go through each
>  set of gridbody tags to render them. As I do this I
> want to construct a path query to determine if the current 
> cell is turned green 
> 
>  <Grid0Row0Col3LimeGreen> if this exist then green. 
> 
> 
> The question is how
> 
> 
> xslt
> 
> <xsl:for-each select="Reports/GridBody0">
> 
>      <xsl:if test="Col3 != ''" > 
> 	<xsl:variable name="rowNo" 
> select="concat('../GridColors/Grid0RowNo',RowNo,'Col3LimeGreen
> ')"></xsl:variable> 
> 	     <xsl:choose>
> 	       <!--If this element exist and we have to render green-->
> 		     <xsl:when test="$rowNo = 1" >-->
> 		                               
> 		        <td align="right" width="60"  
> bordercolor="DarkGray" border="1" bgcolor="LimeGreen">
> 			   <font style='FONT-WEIGHT: 
> normal;Font-Size:XX-Small; COLOR: Black; FONT-FAMILY:Verdana'>      
> 								
> 		
> 			       <xsl:value-of 
> select="format-number(Col3,'#,##0.#')"></xsl:value-of>
> 			   </font>
> 			</td>       
> 		       </xsl:when>
> 
>                       <!--etc-->
>  </xsl:for-each>
>  
> 
> Xml
> 
> <Reports>
>  <GridColors>
>     <Grid0Row0Col3LimeGreen>1</Grid0Row0Col3LimeGreen>
>     <Grid0Row1Col3LimeGreen>1</Grid0Row1Col3LimeGreen> 
> </GridColors>
>    <GridBody0>
>     <MemberUniqueName>[Product].[All Products].[Consumer  
> Electronics]</MemberUniqueName>
>     <MemberCaption>Consumer Electronics</MemberCaption>
>     <RowNo>0</RowNo>
>     <Col0>13458.26555</Col0>
>     <Col1>9952.06343</Col1>
>     <Col2>14633.765640000001</Col2>
>     <Col3>35.230906079544546</Col3>
>     <Col4>-8.032792918227992</Col4>
>   </GridBody0>
>  <GridBody0>
>     <MemberUniqueName>[Product].[All Products].[Domestic 
> Whiteware]</MemberUniqueName>
>     <MemberCaption>Domestic Whiteware</MemberCaption>
>     <RowNo>1</RowNo>
>     <Col0>2983.95073</Col0>
>     <Col1>2632.35801</Col1>
>     <Col2>3400.7199100000003</Col2>
>     <Col3>13.356569230490049</Col3>
>     <Col4>-12.25532213854096</Col4>
>   </GridBody0>
> </Reports>
> 
> 
> <%@ OutputCache Duration="60" VaryByParam="none"%>

Current Thread