[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Creating nested structures


Subject: Re: [xsl] Creating nested structures
From: scott gabelhart <swgabel@xxxxxxxxxxxx>
Date: Fri, 23 Jan 2004 14:31:09 -0500

Wendell Piez wrote:

Hi Scott,

At 12:56 PM 1/23/2004, you wrote:

thanks for the response. I typically create xhtml output that is of the standard flavor of:

<body>

<table>
<tr><td></td></tr>
....
..
etc

</table></body>

For the included xml snippet I added to this post that contains multiple table elements both nested and non-nested I need to create an output structure that different from what I am use to creating.

<body>

<table>
<tr><td></td></tr>
</table><table><tr><td></td><td></td></tr><table><tr><td></td></tr></table></table>



</body>


To confirm: what I see here is input that looks like

<foo>
<bar>
<baz/>
<baz/>
<baz>
<foo>
<bar>
<baz/>
<baz> ...stuff... </baz>
</bar>
</foo>
<baz/>
(more baz ... could be empty, could contain text, could contain more foo)
</bar>
<bar>
(and more)
</bar>
</foo>


...where foo is TABLE, bar is DROW and baz is OBJECT...

But in output you want

<table>
<tr><td></td></tr>
</table><table><tr><td></td><td></td></tr><table><tr><td></td></tr></table></table>




which is (reformatted to show nesting)

<table>
  <tr>
    <td></td>
  </tr>
</table>
<table>
  <tr>
    <td></td>
    <td></td>
  </tr>
  <table>
    <tr>
      <td></td>
    </tr>
  </table>
</table>

-- which is to say that a table inside a table is not inside a cell (a TABLE appearing in an OBJECT should not map to a table inside a td (a cell), but rather directly inside its ancestor table, next to its tr (row) children?

If so, when your input has a TABLE inside an OBJECT (a foo inside a baz), but you don't want its target element (table) inside the OBJECT's target element (td) ... where do you want it? immediately after the row containing the cell (the tr containing the td)?

Sorry for all the alpha-renaming. What I am trying to establish is what the specific required mapping is, if not simply a straight structural mapping of a nested structure into an exactly-congruent nested structure but with different names (the usual case).

Or is this actually the case, and do you really want your result to have tables inside td (cell) elements? which is common enough in HTML ... whereas having an HTML table next to rows directly inside another table is ... umm ... not likely to display cleanly (is it)?

Either way, it can be done. Please clarify.

Cheers,
Wendell

XML Input file to be parsed: <snippet>

<FORMATTED>
<title>Report1</title>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" OCCURENCE="1">
<DPROW>
<OBJECT ALIGN="left" STYLE="background-color:#FFFFFF;" HEIGHT="10"/>
</DPROW>
</TABLE>
<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="842" OCCURENCE="2">
<DPROW>
<OBJECT ALIGN="left" WIDTH="3"/>
<OBJECT>
<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0" OCCURENCE="2">
<DPROW>
<OBJECT WIDTH="4" HEIGHT="6"/>
<OBJECT WIDTH="22" HEIGHT="6"/>
<OBJECT WIDTH="67" HEIGHT="6"/>
<OBJECT WIDTH="2" HEIGHT="6"/>
<OBJECT WIDTH="211" HEIGHT="6"/>
<OBJECT WIDTH="2" HEIGHT="6"/>
<OBJECT WIDTH="273" HEIGHT="6"/>
<OBJECT WIDTH="48" HEIGHT="6"/>
<OBJECT WIDTH="92" HEIGHT="6"/>
<OBJECT WIDTH="2" HEIGHT="6"/>
<OBJECT WIDTH="2" HEIGHT="6"/>
<OBJECT WIDTH="82" HEIGHT="6"/>
<OBJECT WIDTH="6" HEIGHT="6"/>
<OBJECT WIDTH="22" HEIGHT="6"/>
<OBJECT WIDTH="5" HEIGHT="6"/>
</DPROW>
<DPROW>
<OBJECT WIDTH="4"/>
<OBJECT WIDTH="22"/>
<OBJECT WIDTH="67" VALIGN="TOP">
<TABLE BORDER="0" WIDTH="66" OCCURENCE="2">
<DPROW>
<OBJECT STYLE="color:#000000;font-family:Arial;font-size:10pt;background-color:#FFFFFF;height:20px;font-weight:bold;">Agent ID:</OBJECT>
</DPROW>
</TABLE>
</OBJECT>
<OBJECT WIDTH="2" COLSPAN="2" VALIGN="TOP">
<TABLE BORDER="0" WIDTH="212" OCCURENCE="2">
<DPROW>
<OBJECT STYLE="color:#000000;font-family:Arial;font-size:12pt;background-color:#FFFFFF;height:20px;font-weight:bold;">100008</OBJECT>


</DPROW>
</TABLE>
</OBJECT>
<OBJECT WIDTH="2"/>
<OBJECT WIDTH="273"/>
<OBJECT WIDTH="48"/>
<OBJECT WIDTH="92"/>
<OBJECT WIDTH="2"/>
<OBJECT WIDTH="2" COLSPAN="2" VALIGN="TOP">
<TABLE BORDER="0" WIDTH="84" OCCURENCE="2">
<DPROW>
<OBJECT STYLE="color:#000000;font-family:Arial;font-size:10pt;background-color:#FFFFFF;height:20px;font-weight:bold;">12/19/2003</OBJECT>


</DPROW>
</TABLE>
</OBJECT>
<OBJECT WIDTH="6"/>
<OBJECT WIDTH="22"/>
<OBJECT WIDTH="5"/>
<OBJECT HEIGHT="20"/>
</DPROW>
<DPROW>
<OBJECT WIDTH="4"/>
<OBJECT WIDTH="22" COLSPAN="3" ROWSPAN="2" VALIGN="TOP">
<TABLE BORDER="0" WIDTH="90" OCCURENCE="2">
<DPROW>
<OBJECT STYLE="color:#000000;font-family:Arial;font-size:10pt;background-color:#FFFFFF;height:20px;font-weight:bold;">Agent Name:</OBJECT>
</DPROW>
</TABLE>
</OBJECT>





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



Wendell,

your question: "Or is this actually the case, and do you really want your result to have tables inside td (cell) elements? which is common enough in HTML"

Answer is "yes I want to have my results to have tables inside td elements.

I have included a snippet of the html input I parse to the xml structure I listed above. Also <TABLE> = <table>; <DPROW> = <tr>; and <OBJECT> = <td>

input html snippet:

<TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0" WIDTH="842"><TR><TD WIDTH="3"></TD><TD><TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0"><TR HEIGHT="6"><TD WIDTH="4"></TD><TD WIDTH="22"></TD><TD WIDTH="67"></TD><TD WIDTH="2"></TD><TD WIDTH="211"></TD><TD WIDTH="2"></TD><TD WIDTH="273"></TD><TD WIDTH="48"></TD><TD WIDTH="92"></TD><TD WIDTH="2"></TD><TD WIDTH="2"></TD><TD WIDTH="82"></TD><TD WIDTH="6"></TD><TD WIDTH="22"></TD><TD WIDTH="5"></TD></TR><TR><TD WIDTH="4"></TD><TD WIDTH="22"></TD><TD WIDTH="67" VALIGN="TOP"><TABLE BORDER="0" WIDTH="66"><TR><TD CLASS="s2">Agent ID:</TD></TR></TABLE></TD><TD WIDTH="2" COLSPAN="2" VALIGN="TOP"><TABLE BORDER="0" WIDTH="212"><TR><TD CLASS="s3">100008</TD></TR></TABLE></TD><TD WIDTH="2"></TD><TD WIDTH="273"></TD><TD WIDTH="48"></TD><TD WIDTH="92"></TD><TD WIDTH="2"></TD><TD WIDTH="2" COLSPAN="2" VALIGN="TOP"><TABLE BORDER="0" WIDTH="84"><TR><TD CLASS="s4">12/19/2003</TD></TR></TABLE></TD><TD WIDTH="6"></TD><TD WIDTH="22"></TD><TD WIDTH="5"></TD><TD HEIGHT="20"></TD></TR><TR><TD WIDTH="4"></TD><TD WIDTH="22" COLSPAN="3" ROWSPAN="2" VALIGN="TOP"><TABLE BORDER="0" WIDTH="90"><TR><TD CLASS="s2">Agent Name:</TD></TR></TABLE></TD><TD WIDTH="211"></TD><TD WIDTH="2"></TD><TD WIDTH="273"></TD><TD WIDTH="48"></TD><TD WIDTH="92" COLSPAN="3" ROWSPAN="2" VALIGN="TOP"><TABLE BORDER="0" WIDTH="96"><TR><TD CLASS="s4">Report Date:</TD></TR></TABLE></TD><TD WIDTH="82" COLSPAN="3" ROWSPAN="2" VALIGN="TOP"><TABLE BORDER="0"

- Scott



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



Current Thread
Keywords