Rephrasing the problem [was Re: Second try: Search and
On Mon, May 20, 2002 at 10:00:42AM -0700, Stuart Celarier wrote: > Zack, when you've got a hammer in your hand, everything starts to look > like a nail. XSLT (the hammer) transforms XML data (true nails). You > seem to want to perform search-and-replace text processing (false nails) > as well. > > XPath expressions provide some string manipulation facilities  which > might be what you are looking for, but that may not be a very efficient > way to go. Are you sure that XSLT is the best tool for your job? > > I may have missed the point, it is a little hard to tell from the > description you provided. Consider providing a succinct, to-the-point > sample of the inputs and the desired output. Reduce the problem to its > essence and it may be more clear to me what you are after. Hmm.. That makes three people who felt my problem description was unclear (the third emailed me privately). I've looked over Andrew's solution but haven't had a chance to try it yet. But I'll re-describe the problem anyway. Maybe it'll be clearer to folks. Note that the sample input and output have been changed in basic ways from my original post. Basic Problem Summary To perform a search-and-replace on the first occurrence of each of a set of strings defined in <quote> tags, within the text portions of a set of <section> tags. Sample Input <kc> <quotes> <quote who="Peter P. Peters"/> <quote who="Bernadette Peters"/> <quote who="Seth David Schoen"/> </quotes> <section> <p>This paragraph refers once to Peter P. Peters, once to Bernadette Peters, and then again to Peter P. Peters.</p> </section> <section> <p>This paragraph refers to Harry Smith and Seth David Schoen. Also Bernadette Peters.</p> </section> </kc> Desired Output <kc> <quotes> <quote who="Peter P. Peters"/> <quote who="Bernadette Peters"/> <quote who="Seth David Schoen"/> </quotes> <section> <p>This paragraph refers once to Peter P. Peters [<a href="people/Peter_P._Peters.html">*</a>], once to Bernadette Peters [<a href="people/Bernadette_Peters.html">*</a>], and then again to Peter P. Peters.</p> </section> <section> <p>This paragraph refers to Harry Smith and Seth David Schoen [<a href="people/Seth_David_Schoen.html">*</a>]. Also Bernadette Peters [<a href="people/Bernadette_Peters.html">*</a>]</p> </section> </kc> Discussion In the above, Peter P. Peters, Bernadette Peters, and Seth David Schoen are all matched, the first time they appear in a given <section>. When Peter P. Peters appears a second time in a single section he is not matched again, while Bernadette Peters is matched when she appears again, because it is in a different section. Harry Smith is never matched because he does not appear in a <quote> tag. Is that a little better? Be well, Zack > > Cheers, > Stuart > >  http://www.w3.org/TR/xpath#section-String-Functions > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > -- Zack Brown XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format