xsl-list
[Top] [All Lists]

RE: Number of scans required ??

2003-08-07 16:34:01
Hi Michael,

Thanks a lot for replying.

Well my document is big enough thats why i haven't pasted it there.
But i can generailize how it is and then i think it will give you proper idea.

<RootNode>
  <FirstChild> Some Attributes which are columns : </FirstChild>
      <A> More column names as attributes.
          <B> More column for this table (corresponding to DB)
            One or two more level of identations like this.
          </B>
      </A>
   </FirstChild>

   <NodeNameSameASFirstChild>
       <A>
          <B>
             <C> Can have this new table </C>
           </B>
       </A>
    </NodeNameSameAsFirstChild>

     |
     |
 </Root>


So actually i m trying to get the column names(Attributes) of all the tables 
(elements). In this Root contains 6 elements and within this six element there 
is the possibility that some table names might come twice or more than that 
and some will come once once or sometable name might not come.

I m forming text output like this

RootID,FirstColOfRoot,SecondColOfRoot,
FirstChildID,RootID, (Link to parent i..e Primary Key , Foriegn Key)
FirstChildFirstTable'sID, FirstChildID, FirstChildFirstTableCol1, 
FirstChildFirstTableCol2, 
FirstChildSecondTable'sID, FirstChildID, FirstChildSecondTableCol1,
FirstChildSeconDTableCol2 and so on.

For the above example

RootID,FCID,RootCol1,RootCol2,FCID,RootID,AID,FCID,Acol1,ACol2,BID, 
FCID,BCol1,BCol2,BCol3,CID,FCID,CCol1,CCol2, ...so on...

Well as you can make out i m generating unique key value for every table and 
relation child to its parent. For this i have used generateid() function. So 
basically i want to read all the tables in the given xsl only once and get all 
the column names in my first line.
So in the first line there will be only column names of the data which is 
going to follow. I have used comma as a sepertor. And as i shown you above 
there is the possiblity that one table name will appear under some element and 
in another it wont. I HOPE I M NOT CONFUSING.

Since the requirment is like this thats why i asked do i hv to scan it twice 
or what ?

Further as i have aske this question seperately about generate-id function 
will i get the same id bcos my input is going to same for the 6 scans. I m 
forming 6 output files. (If i need to scan it twice i will need to run it 12 
times this is not the question) THEN IS IT POSSIBLE THAT I WONT GET UNIQUE ID 
FOR MY NODES ??

I hope i have not confused the community with the complicated email like this 
but i m trying to achieve the result thru better solution.

Eagerly waiting for your reply.

Regards,




Date: Thu, 7 Aug 2003 16:37:51 +0100
From: "Michael Kay" <mhk(_at_)mhk(_dot_)me(_dot_)uk>
Subject: RE: [xsl] Number of scans required ??


I am trying to put the name of the elements which corresponds
to table or
column names in my database as my topmost line the output txt file.

Then i have to get the data for all columns and these files
are big i.e.
average 20 MBS.

SO DO I REQUIRE TO HAVE TWO SCANS FOR THIS ?? OR IS IT
POSSIBLE TO ACHIEVE IT
IN ONE SCAN ??

You haven't shown your document structure so I'm making guesses here.

If all the column names are present in the first row, then you can
output them as, for example,

<xsl:for-each select="row[1]/*">
<th><xsl:value-of select="name(.)"/></th>
</xsl:for-each>

Any half-decent XSLT processor will be able to do this without scanning
the whole document.


<

And in both the cases, I would be able to append the output
of second scan to
the first using insertion operation i.e. something like ">>"
or is there some
other way to do this ?


No, you don't want to use text concatenation for this. Think of it as
building a result tree, with the structure:

TABLE
HEADING
COLUMN1
COLUMN2
BODY
ROW1
CELL1,1
CELL1,2

and then serializing this result tree as text.

Michael Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>