Wendell Piez wrote:
Hi Scott,
I would expect your XSLT to look something like this:
<xsl:template match="TABLE">
<table>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="DROW">
<tr>
<xsl:apply-templates/>
</tr>
</xsl:template>
<xsl:template match="OBJECT">
<td>
<!-- first, whatever you want to do to show empty objects -->
...
<!-- then, continue tree traversal for the data content
and the nested tables by applying templates -->
<xsl:apply-templates/>
</td>
</xsl:template>
With appropriate attribute processing for copying in the widths,
borders etc.
See, Jarno said it was simple.... Note also that "closing tags" are
not an issue here ... nor are they ever unless you are writing
unorthodox XSLT for some peculiar reason. (And even then you might be
writing them, but can't read them: as a proficient XSLT programmer you
know that the data model knows nothing of "tags".)
The question is, since you say you know XSLT well, but ask for help
with XPath ... but this is a straightforward, XSLT-default descent
(and therefore all the XPath is built in) ... what are we missing?
Cheers,
Wendell
At 08:41 AM 1/23/2004, you wrote:
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>
Desired output is xhtml<-creating xhtml output I have no problem
with. The problem I am stuck on is given the above nested input file
I need to know when to transform the closing </TABLE> element to
</table> in my transformed output. Once I have completed that task I
need to be able to use the same logic for the DPROW and OBJECT
structure.
- Scott
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
======================================================================
Wendell Piez
mailto:wapiez(_at_)mulberrytech(_dot_)com
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,
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>
- Scott
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list