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: Xpath predicates question


Amanda Birmingham wrote:
> Hi, List,
> 
> I've got a question about using predicates in xpath ... I know you can 
> select something like
> 
> /library/book[title = MobyDick]

You mean

  /library/book[title = 'MobyDick']

> but can you do something like
> 
> /library/book[title = <xsl:value-of select = "/personal_info/favorite_book" />]

Yes, like this... didn't you try it?

  /library/book[title = /personal_info/favorite_book]

Although this example would not actually work, since a well-formed document
cannot have both a /library and a /personal_info, but in general, if you get
the paths right, it will be fine. Show us your XML and what output you want,
if you can't figure it out.

Node-sets are tricky when making comparisons. For each book element, you're
comparing a set of title elements with a set of favorite_book elements. The
comparison will be true if the string-value of any title matches the
string-value of any of favorite_book. "string-value" is XPath terminology;
it generally means the text content of the node, or the string equivalent of 
whatever the object is.

   - Mike
____________________________________________________________________________
  mike j. brown                   |  xml/xslt: http://skew.org/xml/
  denver/boulder, colorado, usa   |  resume: http://skew.org/~mike/resume/

 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]