Subject: Re: [xsl] Counting Child Nodes From: "Jorge A. Salido" <jorgesalido@xxxxxxxxx> Date: 26 Nov 2002 17:03:50 -0600 |
I suppose you could just do: count(/data/data) to find T. And your pseudocode seems pretty straightforward to convert to xsl, at least that is my Opinion. I didn´t quite get what was what you called optimum,or how did you intend to get the number of columns and rows, but it should be easy anyway. Jorge On Tue, 2002-11-26 at 16:38, bix xslt wrote: > All, > > As I've been developing my xsl scripts, I've realized that it would be > beneficial to be able to write my xslt in such a way that it would > dynamically format my page for an optimal view based on a few factors. > Essentially, I have a very large table which contains data from its child > node and its grandchild node. An example xml file would be: > > <data><text>Title for web page</text> > <data><text>Motivation</text> > <data><text>White Pages</text></data> > <data><text>References</text></data> > </data> > <data><text>Requirements</text> > <data><text>Software</text></data> > <data><text>Hardware</text></data> > </data> > <data><text>Design</text> > <data><text>Interfaces</text> > <data><text>Hardware/Software</text></data> > <data><text>Legacy Software</text></data> > </data> > <data><text>Functions</text></data> > </data> > <data><text>Implementation</text></data> > <data><text>Verification</text></data> > <data><text>Documentation</text></data> > <data><text>Archive</text></data> > </data> > > Note that there are 7 <data> elements that are children of the root > node. In my table, I could display each one in their own row or column, but > I would prefer to put three children on the first and second lines, and then > a single child on the third line. An example of this would be: > > One per column: > [Motivation] [Requirements] [Design] [Implementation] . > .. . . > > One per row: > [Motivation] > [Requirements] > [Design] > . > . > > Optimal View: > [Motivation] [Requirements] [Design] > [Implementation] [Verification] [Documentation] > [Archives] > > The algorithm I would use to determine how many rows and columns would > be as follows: > T = Total number of children > R = Number of children displayed per row > C = Number of columns needed > > <!-- find T --> > T = ?? > > <!-- initialize the values --> > set R = 1 > set C = T > > <!-- setup a loop to find the best numbers --> > while ( R < C and C > 1 ) > R = R + 1 > C = C - 1 > > <!-- numbers should now be close to optimal, so start displaying --> > > > So, my question is two-fold: How do I find T, and is there a slick way > of converting the psuedo code above into XSLT? > > Thanks, > Bix > > > > > > _________________________________________________________________ > Tired of spam? Get advanced junk mail protection with MSN 8. > http://join.msn.com/?page=features/junkmail > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Counting Child Nodes, bix xslt | Thread | Re: [xsl] Counting Child Nodes, Ritu |
[xsl] Counting Child Nodes, bix xslt | Date | Re: [xsl] Counting Child Nodes, Ritu |
Month |