[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Re: how to optimize recursive algorithm?

Subject: Re: Re: how to optimize recursive algorithm?
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Sat, 29 Nov 2003 09:24:04 +0100
xsl recursive all elements
> I want to represent this document graphically (in SVG) as a tree structure
> like this:
>
> root
>  |-------------<------------------|
>  |--- ab-------->-----------------|
>  |--- longname -->----- xyz-->---|
>  |                             |--- tuop-->--|
>  |--- last -------->----------------|
>
>
> The problem I submitted refers to the calculation of the width of the
branch
> on the right hand side of each element's name (plus the first branch
> represented as a path going backwards) that should be aligned to the
> rightmost position for all elements.
> Its total length is the maximum of the sum of the length of all elements

Here you are talking about "the maximum of the sum of the length of all
elements" ... ?

What is a "length of an element" ?

"the maximum of the sum of the length of all elements" should be just "the
sum of the length of all elements" -- a sum is just a single number, it is
not meningful to try to find the maximum of a single number.

> residing on each "branch" plus a certain fixed amount to leave some room
> between the elements.
>
> In this case it would be the maximum between:

Now you are just looking for the maximum of several numbers, not the maximum
of their sum.

> the length of "ab"
> the length of "longname" plus "xyz"
> the length of  "longname" plus "tuop".
> the length of "last".
>

Summary:
   It is not clear what you want to achieve. However, I guess the following
link will be useful:

http://skew.org/xml/stylesheets/treeview/ascii/

Also, in case you need to find the element with the maximum depth, this
question has been asked before and has a nice and efficient solution (e.g.
using FXSL) -- see
http://sources.redhat.com/ml/xsl-list/2002-05/msg00611.html

Pardon me in case my guesses are wrong.



=====
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.