[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
RE: [xsl] Number of scans required ??
Subject: RE: [xsl] Number of scans required ?? From: Dipesh Khakhkhar <dkhakhkh@xxxxxxxxxxxxxxx> Date: Thu, 14 Aug 2003 09:27:25 -0400 |
Hi, Thanks a lot for replying and explaining me. As all of you gurus are saying that it is possible, then it must be. May be i am not able to find the proper solution for it. As michael said I want exactly that. Header descrbing the column name and data for that column names will follow. But there can be situation like same table will have m columns at one place and n columns at another place in the input. Below is the simulated input xml file. ==================================== <?xml version="1.0" encoding="UTF-8"?> <Root> <Tables> <TABLE NAME="Client_Agent"> <ROW> <COLUMN NAME="Agent Name">eXpress NS Client</COLUMN> <COLUMN NAME="Product Version">5.5.0.517</COLUMN> <COLUMN NAME="Build Number">517</COLUMN> </ROW> <ROW> <COLUMN NAME="Agent Name">eXpress Inventory Solution</COLUMN> <COLUMN NAME="Product Version">5.5.0.424</COLUMN> <COLUMN NAME="Build Number">424</COLUMN> </ROW> </TABLE> <TABLE NAME="Client_Agent"> <ROW> <COLUMN NAME="Agent Name">eXpress NS Client</COLUMN> <COLUMN NAME="Install Path">C:\Program Files\ABC\eXpress\NS Client\Software Delivery\Software Packages\{01B54EB5-3679-4C73-9E10-E169D5EA8C59}</COLUMN> <COLUMN NAME="Product Version">5.5.0.519</COLUMN> <COLUMN NAME="Build Number">519</COLUMN> </ROW> <ROW> <COLUMN NAME="Agent Name">eXpress Inventory Solution</COLUMN> <COLUMN NAME="Install Path">C:\Program Files\ABC\eXpress\NS Client\Software Delivery\Software Packages\{01B54EB5-4579-4C73-9E10-E169D5DA9E59}</COLUMN> <COLUMN NAME="Product Version">5.5.0.428</COLUMN> <COLUMN NAME="Build Number">428</COLUMN> </ROW> </TABLE> </Tables> </Root> ================================================================ And i m trying to get output something like this Agent Name,Install Path,Product Version,Build Number eXpress NS Client,,5.5.0.517,517 eXpress Inventory Solution,,5.5.0.424,424 eXpress NS Client,C:\Program Files\ABC\eXpress\NS Client\Software Delivery\Software Packages\{01B54EB5-3679-4C73-9E10-E169D5EA8C59},5.5.0.519,519 eXpress Inventory Solution,C:\Program Files\ABC\eXpress\NS Client\Software Delivery\Software Packages\{01B54EB5-4579-4C73-9E10-E169D5DA9E59},5.5.0.428,428 ==================================================================== As of now i have shown that there is only one table and columns within it. There are other tables also but to make things simple i have shown only one table withn tables tag. I was not able to produce the desired output. I hope with these as input and output there should be some way to get the above mentioned output. Thanks a lot to all you gurus for taking out your time to read my problem. Eagerly waiting for reply. Regards, Dipesh Date: Thu, 14 Aug 2003 10:17:29 +0100 From: David Carlisle <davidc@xxxxxxxxx> Subject: Re: [xsl] Number of scans required ?? > If i got it properly, you mean to say that once i have written something in > the output file i can not come to the point to rewrite something again in the > same output file?? yes > So the kind of output I want to obtain is impossible with xsl ? No. You can produce any XML output with XSLT but you specify the entire tree. A system may evaluate your templates in any order it wants so long as the final result is as specified. David ==================================================================== Date: Thu, 14 Aug 2003 09:36:36 +0100 From: "Michael Kay" <mhk@xxxxxxxxx> Subject: RE: [xsl] Number of scans required ?? > If i got it properly, you mean to say that once i have > written something in > the output file i can not come to the point to rewrite > something again in the > same output file?? So the kind of output I want to obtain is > impossible with xsl ? Everything is possible in XSLT, but you have to understand its processing model and use it the way it was designed to be used. The result of the transformation is a tree. The structure of the result tree matches the structure of the stylesheet used to create it (the stylesheet consists of templates for the nodes in the result tree). You therefore need to design the stylesheet according to the structure of the desired output. Where the structure of the source tree and result tree are different, a common mistake is to try and model the stylesheet on the structure of the source tree: this doesn't work. Your mental process should be to picture the result tree that you want to produce, then for each node in the result tree, to think "where does the source data for this node come from", and to write the template thatproduces this node in the result tree to fetch the required data from the source document either using direct XPath expressions, or by using XSLT-level instructions (apply-templates and for-each) to navigate to the relevant part of the source tree. I've tried to get this across to you in several of my replies on this thread. The very title of the thread "number of scans required" shows that you are thinking about XSLT processing the wrong way. Your thinking should be output-driven, not input-driven. In your case the structure of the result tree is a header followed by a body. The header contains entries describing columns. The body contains data rows, and each data row contains a sequence of values. This, in essence, gives you the high level design of your stylesheet. Michael Kay ==================================================================== Date: Wed, 13 Aug 2003 16:49:39 -0400 From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Subject: Re: [xsl] Number of scans required ?? Dipesh, At 02:40 PM 8/13/2003, you wrote: >If i got it properly, you mean to say that once i have written something in >the output file i can not come to the point to rewrite something again in the >same output file?? Correct. That's not the way XSLT works. In fact, you have very little control -- nor do you need it -- over writing anything. Rather, your task is to "build" something ... a tree of nodes, which when completed can be written out, or processed in some other way. > So the kind of output I want to obtain is impossible with >xsl ? This is not so: it is almost certainly possible. The solution is in a set of templates with instructions that build the output you want, as a tree of nodes (which we can then have written). Without seeing your input and hearing what you want to do with it, no one can say what these templates will look like. But XSLT is an excellent tool for all kinds of rearrangements of data. Please post again with more details about your actual problem -- only by seeing the problem can we assess what the best solution is. At this point we only know it's not to "rewrite something again in the same output file", since this just isn't the way things are done in XSLT. Cheers, Wendell ====================================================================== Wendell Piez 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Number of scans required , David Carlisle | Thread | Re: [xsl] Number of scans required , David Carlisle |
Re: [xsl] Walking the tree, David Carlisle | Date | libxslt disable-output-escaping was, Gary Cornelius |
Month |