[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: previous sibiling node value

Subject: Re: previous sibiling node value
From: Piet van Oostrum <piet@xxxxxxxxxxxxxx>
Date: Mon, 15 Nov 2010 00:06:47 -0400
Re:  previous sibiling node value
ram wrote:

 > Thanks that perfectly works. 
 >        let us suppose if i get qmNumber as 01 then i need to get
 > BRKQM if i get qmNumber is 02 then i need to get BEKQM i have written
 > the logic like below but I am not able to go second QMNUmber
 > 
 > if QMNumber is 2 its failing.Its showign only qmnumber 1
 > 
 > $qmNumberFromContext is variable which will come either 01/02
 > $serviceType is Response
 > 
 > <xsl:choose> <xsl:when
 > test="$serviceType/QMNumber=$qmNumberFromContext"> <xsl:value-of
 >           select="$qmNumberFromContext/precedingibling::QMName[1]/text()"/>
 > 
 > 	</xsl:when>
 >          <xsl:otherwise/>  
 >  
 > </xsl:choose>

Your example xml doesn't have a Response element, so what does the
$serviceType/ do there? And certainly
select="$qmNumberFromContext/precedingibling::QMName[1]/text() doesn't
make sense, even if preceding-sibling would be correctly
spelled. Hint: never retype your code but copy and paste.

The following works:

  <xsl:template match="/">
    <xsl:apply-templates select="/*/QMNumber[.=$qmNumberFromContext]"/>
  </xsl:template>
  <xsl:template match="QMNumber">
    <xsl:choose>
	<xsl:when test="text()=$qmNumberFromContext">
	  <xsl:value-of select="preceding-sibling::QMName[1]/text()"/>
	</xsl:when>
    </xsl:choose>
  </xsl:template>

And in XSLT 2.0 you can use:

  <xsl:template match="QMNumber[.=$qmNumberFromContext]">
    <xsl:value-of select="preceding-sibling::QMName[1]/text()"/>
  </xsl:template>


-- 
Piet van Oostrum
Cochabamba. URL: http://pietvanoostrum.com/
Nu Fair Trade woonartikelen op http://www.zylja.com

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.