Subject: [xsl] Re: Re: Using XSLT to add markup to a document From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx> Date: Mon, 7 Jul 2003 21:56:07 +0200 |
> > While this is a nice solution, it will not produce good > > results in the case when one of the search strings is the > > start of another of the search strings. > > I don't think this is true - it just requires intelligent ordering of the > xsl:when statements. You'd want the check for the longer string to appear > first. Unless I don't understand how xsl:choose works. I agree. But I was discussing the solution as it was originally presented. Ordering the xsl:when clauses by the decreasing length of the search strings will provide a solution when the longest string should be searched for first. However, this will make it impossible to support the general case when the caller is allowed to specify the order in which to search for each string. > > > Also, all possible search strings are hard-coded in the code > > within an xsl:choose. > > Yes. Not very general, but adequate for everything that I need to do. > > > > This is not going to help in the case when we need to call > > this template, passing it a parameter containing an unknown > > number of search strings. > > Yes. I guess you could have a different stylesheet that generated the code > of the choose for you. So, this would be a transformation, the result of which is another transformation. > > > > > Even if you try to use the xsl:choose approach with a > > moderate number of predefined strings (e.g. 5 - 10), the code > > will increase quadratically to the number of search strings. > > I don't understand this. For each string you are interested in, there is > one xsl:when statement. Why is that quadratic? I was wrong here -- just 2 * N xsl:call-template instructions. In this particular case N was 2, 2 * N was 4 and it just happens that 2 * N = N^2 2 * N is much shorter. And, of course, if the code will be generated (not manually produced), 2 * N is not such a problem. The two-stage solution requires the produced stylesheet to be further loaded and executed and this may affect the convenience and efficiency of this approach. As I said earlier, this is a nice solution and it would be easy to use in the simple cases. ===== Cheers, Dimitre Novatchev. http://fxsl.sourceforge.net/ -- the home of FXSL XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Re: Using XSLT to add mar, McNally, David | Thread | [xsl] Re: Re: Using XSLT to add mar, Dimitre Novatchev |
AW: [xsl] XSLT encoding problem, Markus Abt | Date | AW: [xsl] an Xpath question - $tag/, Markus Abt |
Month |