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

RE: How to filter nodes on attribute values

Subject: RE: How to filter nodes on attribute values
From: "XSLList" <xsllist@xxxxxxxxxxxxx>
Date: Mon, 10 Mar 2003 22:46:56 -0500
xml filter nodes
If you don't like my solution create separate templates for each type you
want of the form:

<xsl:template match="Annotation[@type='boring']">

which will give you more granular control over formatting.

Jeff


<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >
<xsl:output method="html"/>

<xsl:template match="/">
	<html>
		<style>
			.interesting {color: red;}
			.boring {color: green;}
		</style>
		<body>
			<xsl:apply-templates/>
		</body>
	</html>
</xsl:template>

<xsl:template match="Annotation">
	<p class="{@type}">
		<br/>
		Author = <xsl:value-of select="book/author"/><br/>
		Title = <xsl:value-of select="book/title"/><br/>
	</p>
</xsl:template>

</xsl:stylesheet>


<?xml version="1.0"?>
<Annotations>
	 <Annotation type="interesting">
	    <book id="bk106">
	      <author>Randall, Cynthia</author>
	      <title>Lover Birds</title>
	    </book>
	</Annotation>
	<Annotation type="boring">
	   <book id="bk102">
	      <author>Ralls, Kim</author>
	      <title>Midnight Rain</title>
	    </book>
	</Annotation>
	<Annotation type="indifferent">
	   <book id="bk102">
	      <author>Ledbetter, James</author>
			<title>Starving to Death on $200 Million</title>
	    </book>
	</Annotation>
</Annotations>


>Hello,
>I have another problem.
>
>I wish to apply formatting on a set of nodes which have a certain value
>in the attribute.
>I mean -
> <Annotation type="interesting">
>    <book id="bk106">
>      <author>Randall, Cynthia</author>
>      <title>Lover Birds</title>
>    </book>
></Annotation>
><Annotation type="boring">
>   <book id="bk102">
>      <author>Ralls, Kim</author>
>      <title>Midnight Rain</title>
>    </book>
></Annotation>
>-------------------
>So that I can show all nodes ANNOTATION with
>type="interesting" with RED
>colored font and
>all nodes ANNOTAITON with type="boring" with GREEN colored font.
>Could somebody please guide me how to do this.
>I donot wish to use When or If because I have to use
>apply-imports which
>doesnot work with When and If.
>
>Thanks in advance
>Ankit


 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.