This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Predicates using current node-set


Take a look at the current() function.

You probably want something like:

  items[@code=current()/@code()]

Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com 

> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com 
> [mailto:owner-xsl-list@lists.mulberrytech.com] On Behalf Of 
> Nordström, Jonas
> Sent: 02 October 2002 10:27
> To: 'xsl-list@lists.mulberrytech.com'
> Subject: [xsl] Predicates using current node-set
> 
> 
> I have a problem using predicate expressions where I compare 
> an attribute in the node-set to an attribute in the "current 
> node-set". I have problems explaing this, so here's an example:
> 
> xml file:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <?xml-stylesheet type="text/xsl" href="paytest.xsl"?> <payments>
> 	<oldpayments>
> 		<oldpayment payno="1" amount="100" ref="a" />
> 		<oldpayment payno="2" amount="200" ref="b" />
> 		<oldpayment payno="3" amount="300" ref="c" />
> 	</oldpayments>
> 	<newpayments>
> 		<newpayment Payno="3" amount="300" />
> 		<newpayment Payno="4" amount="300" />
> 	</newpayments>
> </payments>
> 
> xsl file:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> <xsl:output method="html"/>
> 
> <xsl:template match="/">
> <html>
> <head><title>test</title></head>
> <body>
> <xsl:apply-templates 
> select="/payments/newpayments/newpayment" /> </body> </html> 
> </xsl:template>
> 
> <xsl:template match="/payments/newpayments/newpayment">
> 	Payno: <xsl:value-of select="@Payno"/> 
> 	Amount: <xsl:value-of select="@amount"/>
> 	<xsl:if test="/payments/oldpayments/oldpayment/@payno = @Payno">
> 		Ref: <xsl:value-of 
> select="/payments/oldpayments/oldpayment[@payno=@Payno]/@ref"/>
> 	</xsl:if>
> 	<br/>
> </xsl:template>
> 
> Result in browser:
> Payno: 3 Amount: 300 Ref: 
> Payno: 4 Amount: 300
> 
> I wanted the "ref" attribute to be printed, but I cant work 
> out how to match the oldpayment payno with the newpayment Payno
> 
> 
> Vendor: Microsoft
> Vendor URL: http://www.microsoft.com
> 
> Jonas Nordstrom
> Sigma Exallon AB
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]