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]
Other format: [Raw text]

Re: Q: XPath Expression for Multiple Attribute testing in the same sub-element



Many Thanks - This nest is something I did not see in any of the book I
was looking at. Maybe it should be in the FAQ :-)

 --- Peter Davis <pdavis152@attbi.com> wrote: > On Wednesday 20 March
2002 18:24, Peter Bray wrote:
> > Greetings,
> >
> > 	Given an XML document like the following except with multiple
> > products, I wish to select all products of a given classification
> but
> > only if that is their primary classification.
> >
> > <document>
> >   <product name="gdbm">
> >     <classificationlist>
> >       <classification class="GNUVersion" primary="true"/>
> >       <classification class="Library"    primary="false"/>
> >     </classificationlist>
> >    </product>
> >    ....
> > </document>
> >
> > So in <xsl:apply-templates select=""> I what to say
> > 	SELECT ALL <product>
> >           SUCH THAT classificationlist/classification/@class =
> $class
> > 	        AND classificationlist/classification/@primary = 'true'
> >
> 
> <xsl:template match="document">
>   <xsl:apply-templates 
> select="product[classificationlist/classification[@class = $class and
> 
> @primary = 'true']]"/>
> </xsl:template>
> 
> should do the trick.  The trick is to make the @class and @primary
> evaluate 
> relative to the same <classification> -- using two layers of
> predicates will 
> allow that.
> 
> -- 
> Peter Davis
> It is wrong always, everywhere and for everyone to believe anything
> upon
> insufficient evidence.
> - W. K. Clifford, British philosopher, circa 1876
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>  

http://movies.yahoo.com.au - Yahoo! Movies
- Vote for your nominees in our online Oscars pool.

 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]