[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: First occurrence of glossary term in whole documen
Richard,
At 02:06 PM 7/30/2008, you wrote: Ooops, that isn't true. I can't pass the result document down because the variable isn't updated until after the full file is processed thereby allowing multiple references to creep in. Right. Indeed, the reference you are checking on behalf of would already have been processed too, thereby introducing a circular dependency. I'll have another go tomorrow using Liam's suggestion. Thanks. R Yes. The essence of Lee's suggestion is that in a declarative mindset, you don't look for a corresponding case that has already been processed; you look for corresponding cases that should be privileged over the current case by some static rule, such as that it appears earlier. Wanting just the first case (and thereby, a single case for every class of corresponding cases) is common, and the key-based idiom to do this (which is generally faster than using XPath to inspect the tree) is something like this: (in your data) <glossterm>ADSL</glossterm>...<glossterm>ADSL</glossterm>... (in your stylesheet) <xsl:key name="glossterm-by-value" match="glossterm" use="string()"/> then in a template matching glossterm (in XSLT 1.0): <xsl:template match="glossterm"> <xsl:if test="generate-id()=generate-id(key('glossterm-by-value',.)[1])"> ... only the first glossterm in the document will pass the test ... </xsl:if> </xsl:template> in XSLT 2.0 one can test ". is key('glossterm-by-value',.)[1]" which is more legible. One can also match on that node, but it leaves the glossterms that don't pass the test unmatched. Cheers, Wendell ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
|
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
|