[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|