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]

Re: Finding a specific element and outputting another related elements value


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


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