Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - Re: How to write nested for loop to generate SVG rectangles? [Thread Next] Re: How to write nested for loop to generate SVG rectangles?To: NULL Date: 9/7/2008 12:08:00 PM 1. XSLT 2.0 (if possible to use) should be recommended. I have several years of happy experience with Saxon (the current version is 9.1) 2. Here are a three ways to write a transformation, so that deep recursion will not cause crashing; 2.1. Use tail recursion. Optimal and fairly easy, if the intended XSLT processor detects and optimizes tail-recursion into simple iteration. Not all XSLT processors do this, however, so the tail-recursive code is not guaranteed to be crashh-less on any XSLT processor (kind of portability issue): 2.2 Divide and Conquer (DVC) processing. Usually straightforward to write, but in some cases can be difficult. Works with any XSLT processor: http://www.topxml.com/code/cod-422_9971_dvc-algorithms-in-xslt.aspx 2.3 The technique described in the link from my previous reply, also known as the "Piez method". Requires that the maximum possible length of the list be known in advance. If the link I provided is not reachable (I am reading now without any problem!), then try this one: http://www.dpawson.co.uk/xsl/sect2/muench.html#d10875e300 The following article discusses in depth most of the above approaches to deep recursion and proposes what is considered an "optimal" approach: http://www.topxml.com/xsl/articles/recurse/ Cheers, Dimitre Novatchev "Siegfried Heintze" <siegfried@h...> wrote in message news:ukQF0TREJHA.4092@T...... > Yowza! That XST2 with the freebie SAXON works! Thanks! And yes, you were > right: I intended to have 13 rectangles in my problem description. > >> Described here: >> >> http://www.topxml.com/code/cod-422_10050_avoiding-an-xslt-processor-crash-due-to-deep-recursive-processing.aspx >> > OK, I'm reading this link now. > Shucks! This link is bad: > http://www.topxml.com/snippetcentral/main.asp?view=viewsnippet&id=v20010126065631. > This seems to be bad too: > http://sources.redhat.com/ml/xsl-list/2001-01/msg00308.html > > So I need some recommendations. Since I only need a couple of dozen > iterations, does that mean I don't have to worry about crashing MSXML3 > because that and other XSLTs require 2000 recursions to crash? > > So my problem is a tad bit more complex that what I stated above and I'm > thinking XSLT2 is the answer. Let me know if I can do it in XSLT1 because > I would love have a larger choice of XSLTs than just SAXON. > > All rectangles are 6.55 mm apart (vertically and horizontally, border to > border or edge to edge) and have a height of 12.5mm. Most rectangles are > 12.5x12.5. So now in Saxon I can get row #1 with 13 rectangles. I have a > total of six rows. Rectangle #14 in Row #1 is 20.7mm and Rectangle #15 is > 20.725mm. > > In row #2 rectangle #14 is 28.925 mm wide. In row 3 rectangle rectangel > #1 is 20.7 mm wide and rectangle #14 is 20.725mm. > In row #3 Rectangle #1 is 20.7mm and rectangle #14 is 20.725mm. > > OK, you get the idea. If you have not guessed already, I'm drawing a > keyboard in SVG. > > Well, I'm not too familiar with XSLT 2 and I'm presently looking for some > tutorials. Can XSLT2 help me with these exceptions better than XSLT1? > > Now, as you probably know, every key on a keyboard has a unique scan code. > For now, I'll just assign the scan codes serially starting at 1 with the > top left most key. Or better yet, a scan code (for now) could be the > concatenation of the row # and the position of the key in that row. > > So what do you recommend: XSLT2 with SAXON or XSLT1 for this task? > After I figure this out, I need to figure out how to make XSLT put the > keycaps on inside of each rectangle for four different languages (I > already have that working with hand coded SVG with CSS styles that turn > off the keycaps for all but one language at a time). This is enough for > one Sunday morning's post. > > Thanks, > Siegfried > > Thanks for all your help! > > | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
