Jump to content

Multiple Constraints on XSLT


Wylbur

Recommended Posts

Hi all;I have the following XML file:

<bookstore>	<book genre="autobiography" publicationdate="1981-03-22" ISBN="1-861003-11-0">		<title>The Autobiography of Benjamin Franklin</title>		<author>			<first-name>Ben</first-name>			<last-name>Franklin</last-name>		</author>		<price>8.99</price>	</book>	<book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2">		<title>A Confidence Man 04</title>		<author>			<first-name>Herman 4</first-name>			<last-name>Melville</last-name>		</author>		<price>14.99</price>	</book>	<book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2">		<title>The Confidence Man 05</title>		<author>			<first-name>Herman 5</first-name>			<last-name>Melville</last-name>		</author>		<price>15.99</price>	</book>	<book genre="novel" publicationdate="1967-11-17" ISBN="0-201-63361-2">		<title>There Was a Confidence Man 06</title>		<author>			<first-name>Herman 6</first-name>			<last-name>Melville</last-name>		</author>		<price>16.99</price>	</book>	<book genre="philosophy" publicationdate="1991-02-15" ISBN="1-861001-57-6">		<title>The Gorgias 02</title>		<author>			<name>Plato 2</name>		</author>		<price>9.99</price>	</book></bookstore>

This XPath reference selects all of the titles where the name of the authorbegins with 'Her':bookstore/book[starts-with(author/first-name,'Her')]/titleresult:A Confidence Man 04The Confidence Man 05There Was a Confidence Man 06The Gorgias 02This XPath reference selects all of the titles where the name of the authorbegins with 'Her', and the title begins with 'The':bookstore/book[starts-with(author/first-name,'Her')]/title[starts-with(../title,'The')]result:The Confidence Man 05There Was a Confidence Man 06My question is: How could I rework the second reference so that it returns the sameresult set, only using a single (the first) predicate?This does not work for me:bookstore/book[starts-with(author/first-name,'Her')][starts-with(author/title,'The')]/titleWhat am I doing wrong?THANKS!!!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...