Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Specify an element in a nodeset directly

From: eric.goforth@-----.---
To: NULL
Date: 10/3/2006 2:52:00 PM


roy axenov wrote:
> eric.goforth@g... wrote:
> > Martin Honnen wrote:
> > > eric.goforth@g... wrote:
> > > > <xsl:value-of select="
> > > > $myblahs/blah[/xpath1/xpath2/someintegervalue]/yada
> > > > "/>
> > >
> > > $myblahs/blah
> > > [/xpath1/xpath2/someintegervalue=position()]/yada
> >
> > Hmmm, that's not working for me.  If I put in a "1" or a
> > "2" it works, but not with the "variable".
>
> Your example is awfully vague. For better results, provide
> a sample XML and a minimum XSLT demonstrating your problem.
>

Roy,

Here's an example of what I'm referring to.  The "does not work"
comment shows what I'm trying to do.  The "this does work" shows where
I'm able to hit the nodeset by hardcoding the parameter.

Thanks,
Eric

<page>
	<contents>
		<ratessummary rec_count="3">
			<rate>
				<ratecode>1</ratecode>
				<myrate>1.1</myrate>
			</rate>
			<rate>
				<ratecode>2</ratecode>
				<myrate>1.2</myrate>
			</rate>
			<rate>
				<ratecode>3</ratecode>
				<myrate>1.3</myrate>
			</rate>
		</ratessummary>
		<thingsummary rec_count="3">
			<thing>
				<short_description>Jim</short_description>
				<description>James</description>
				<thingcode>1</thingcode>
			</thing>
			<thing>
				<short_description>Rick</short_description>
				<description>Richard</description>
				<thingcode>2</thingcode>
			</thing>
			<thing>
				<short_description>Fred</short_description>
				<description>Frederick</description>
				<thingcode>3</thingcode>
			</thing>
		</thingsummary>
	</contents>
</page>

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
	<xsl:template match="/">
		<html>
			<head></head>
			<body>
				<xsl:apply-templates select="page/contents"></xsl:apply-templates>
			</body>
		</html>
	</xsl:template>
	<xsl:template match="contents">
		<table>
			<tr>
				<td class="data">
				    	<xsl:apply-templates select="thingsummary">
						<xsl:with-param name="rates"
select="/page/contents/ratessummary"></xsl:with-param>
					</xsl:apply-templates>
				</td>
			</tr>
		</table>
	</xsl:template>

	  <xsl:template match="thingsummary">

	  <xsl:param name="rates"/>

	    <xsl:value-of select="$rates/rate[1]/org_id"/>

	    <table>
	      <xsl:apply-templates select="thing[(position() mod 2)=1]">
			<xsl:with-param name="rates" select="$rates"></xsl:with-param>
		</xsl:apply-templates>
	    </table>
	  </xsl:template>

	  <xsl:template match="thing[(position() mod 2)=1]">
	  <xsl:param name="rates"/>
	    <tr>
	      <td>
	        <xsl:value-of select="short_description"/>-<xsl:value-of
select="thingcode"/>-<xsl:value-of select="$rates/rate[1]/org_id"/>
	        <!-- This does not work-->
	        test1<xsl:value-of select="$rates/rate[position()=thingcode
]/myrate"/>
	        <!-- This works-->
	        test2<xsl:value-of select="$rates/rate[position()=1]/myrate"/>
	      </td>
	      <xsl:apply-templates select="following-sibling::thing[1]">
			<xsl:with-param name="rates" select="$rates"></xsl:with-param>
		</xsl:apply-templates>
	    </tr>
	  </xsl:template>
	  <xsl:template match="thing[(position() mod 2)=0]">
	  <xsl:param name="rates"/>
	    <td>
	      <xsl:value-of select="short_description"/>-<xsl:value-of
select="thingcode"/><xsl:value-of select="$rates/rate[1]/org_id"/>
	        <!-- This does not work-->
	        test1<xsl:value-of select="$rates/rate[position()=thingcode
]/myrate"/>
	        <!-- This works-->
	        test2<xsl:value-of select="$rates/rate[1]/myrate"/>
	    </td>
	  </xsl:template>
	
</xsl:stylesheet>



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent