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

Re: Column Heads and Column Data problem ??

Subject: Re: Column Heads and Column Data problem ??
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 21 Aug 2003 12:04:12 -0400
count columns
Dipesh,

Your last post actually indicates you are making good progress on building your solution.

Although I can't demonstrate specific algorithms (as I said I find myself rather short of time this week), I can offer some general advice that I believe applies to your case (please forgive the length of the post; as they say "I didn't have time to make it short"):

1. Recognize that although, as we've said, XSLT can do this problem, keep in mind that it's a *hard* problem, not at beginner-level at all -- if only because it requires an intimate understanding of your data set and what you are trying to do with it, which none of us have.

2. It appears from your problem description that you want a solution that is both generalized (accept arbitrary inputs within a certain range), and can be "tuned" to a particular data set -- to do things like establish what order you want your output in, etc. This makes the problem harder, of course (though not impossible).

3. This approach certainly won't get you far:

In other programming language it should be something like this:

 Variable colHeaderForTable1;
 Variable maxColNoForTable1=0;
 For each //Table1
   variable temp = count(no. of columns in this table);
   if (temp > maxColNoForTable1)
       colHeaderForTable1={"ParentID", "SelfID",Getting each column  name
followed by seperator}
 End of For
 Output value of colHeaderForTable1

The reason you'll find it frustrating to try to implement this in XSLT is that the language just doesn't work like this, and doesn't have these constructs. It is not an imperative, procedural language, but rather declarative and functional. That is, it generally does not work by providing a set of commands to the processor; rather, it simply *declares*, for a given input, what a given output will be. Now in problems like yours, which involve lots of querying, testing and rearranging, even an XSLT program will dictate "procedures". Yet it will typically *not* do this by using methods, such as looping or managing "state" generally, common in languages with which you are likely familiar.


For example, your subroutine above is basically a simple query for "give me the values in the table with the most columns", which is a compound of "give me the table with the most columns; now give me its values". XSLT would probably have something like a variable declaration that assigned to a variable the table with the most columns (the first query), followed by a simple processing of that variable to get its values (the second). (It's interesting, because stated this way it's clear to an experienced XSLT user why this is hard to do -- XSLT 1.0 gives you no function to determine which table has the most columns; yet there are several ways to do it known to readers of this list.)

One of the strange ironies of this powerful technology is that it is therefore often easier for people to learn who have *no* programming background, than for those who have enough background to know how these problems are solved using other languages, and who therefore fall back on what they know. Unfortunately, this only makes it worse for them. (In my experience, people who take very quickly and easily to XSLT either have little or no programming background, or have a very deep one.)

Accordingly, I think you would be very well served by taking some time for a crash course in XSLT fundamentals -- seeing how XSLT approaches problems that are easier than yours (especially problems that are easier for it, but that would be harder in a procedural language). If you have the time to give, that is. (If you don't, you're kind of up the creek without a paddle.)

Also, take a good look at documentation on problems similar to yours, some of which you'll find at www.jenitennison.com (on grouping, which is a problem area that encompasses your problem) and in the XSL FAQ at http://www.dpawson.co.uk/xsl/sect2/sect21.html.

4. Several of the things you are trying to do, such as determining which table has the most columns, involve solutions that are not obvious. This is another reason your learning curve is particularly long and steep. Breaking the problem down into simpler ones is likely to help you move forward.

Also, it will help you to ask the list more focused, answerable questions. At this point, it is as though you are asking "how to I cook a seven-course meal?" -- which we can't really explain to you even if you give us the entire menu. It is much easier to answer questions like "how do I chop the onions".

I wish I could help more, but I'm afraid I'm doing all I can given limits on time and the bandwidth of a mailing list.... but I'm sure if you can break your problem down into smaller pieces, you'll find it easier to get help.

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


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.