Subject: transformation: column vs. row order table generation From: "Royappa, Andrew" <royapav@xxxxxxxxxxxx> Date: Thu, 22 Oct 1998 21:49:35 -0500 |
Hi, I am studying the kinds of transformations possible with XSL and am working some simple examples. I like XSL so far, but am finding it difficult to do some seemingly simple tasks. For instance, the current XSL working draft shows how to convert this XML structure into an HTML table: <customers> <customer> <name>...</name> <order>...</order> <order>...</order> </customer> <customer> <name>...</name> <order>...</order> <order>...</order> </customer> ... </customers> The customers are listed by ROW n the table generated by the sample XSL transformation (in http://www.w3.org/TR/1998/WD-xsl-19980818). I'm looking for a way to list customers by COLUMN instead, i.e. each table column would list all the orders of one customer. I can't seem to find a way to do this if there are at least four orders per customer.Here's what I tried. XSL's transformation mechanism seems to want to process each customer's subtree entirely before going on to the next customer, while of course what we want is to process the first order of customer 1, then the first order of customer 2, etc. So this is possible (uniquely) for the FIRST-OF and LAST-OF and NOT-FIRST-OF orders if there are exactly three per customer, but "NOT-FIRST-OF" won't uniquely match the "middle" orders if there's more than one of them. Next, I tried an approach with two templates like this: <xsl:template match="customer[first-of-type()]/order"> <TR> <TD> <xsl:process-children> </TD> *** NO END </TR> here *** </xsl:template> <xsl:template match="customer[last-of-type()]/order"> *** NO BEGIN <TR> here *** <TD> <xsl:process-children> </TD> </TR> </xsl:template> and then another template to match the middle orders. That is, the first template outputs the <TR> and the second rule outputs the </TR>. Now this approach seems bogus, I can't quite put my finger on it except to say that for the <TD> elements to come out right it I think the XSL processor would have to apply a rule repeatedly to an element, which is not allowed. Anyway, XT complains in the first template that it can't find the missing "</TR>" (which I assume this has to do with the target tree construction process). So my question finally boils down to just this: how can one generate a column-order table for this XML fragment ? I'm actually doing this with some other data and translated my work to the "customer" example since it should be familiar, so please excuse any minor errors. Any insight would be appreciated. Thanks, Andrew Royappa Department of Computer Science Millsaps College Jackson, MS 39210 royapav@xxxxxxxxxxxx (601) 974-1360 (601) 974-1397 (FAX) XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[Q] How to define 'result-element' , Kyu-O Jang | Thread | Doubts regarding XSL and DOM, Amit Rekhi |
[Q] How to define 'result-element' , Kyu-O Jang | Date | Doubts regarding XSL and DOM, Amit Rekhi |
Month |