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

Re: Finding a specific element and outputting another

Subject: Re: Finding a specific element and outputting another related elements value
From: Adam Turoff <ziggy@xxxxxxxxx>
Date: Tue, 10 Jul 2001 15:54:02 -0400
java outputting element content
On Tue, Jul 10, 2001 at 03:00:16PM -0400, Linda Zammit wrote:
> Hello all,
> I don't know if this is possible:
> 
> I need to output the contents of one element dependant on the previous
> elements content (i.e. if RemarkQualifier=DIMENSIONS then output '24 @
> 48"X48"X48"'.
> 
> XML:
> <Release>
> 	<OrderRemark>
> 		<RemarkQualifier>DIMENSIONS</RemarkQualifier>
> 		<RemarkText>24 @ 48"X48"X48"</RemarkText>
> 	</OrderRemark>
> </Release>
> <Release>
> 	<OrderRemark>
> 		<RemarkQualifier>PIECES</RemarkQualifier>
> 		<RemarkText>24</RemarkText>
> 	</OrderRemark>
> </Release>

First, list the processing expectations in detail:

	1) From <RemarkText>, 
	2) examine the previous element's content, 
	3) when that element is a RemarkQualifer,
	4) and when that element's content is 'DIMENSIONS'
	5) display the contents of this element.

Here's a solution:

<xsl:template match="RemarkText">  
 <xsl:if test="preceding-sibling::RemarkQualifier[1][text()='DIMENSIONS']">
  <xsl:value-of select="text()"/>
 </xsl:if>
</xsl:template>

That should do it.

Z.


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


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.