[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Rendering an HTML table twice

Subject: Re: Rendering an HTML table twice
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 27 Oct 2000 10:16:29 +0100
render xml as html table
Lee,

>I have an HTML table in an XML doc which I wish to render
>twice, once in the main doc with small fonts, once in a
>pop-up window with large fonts.  Jeni kindly provided
>assistance and code to render the TABLE element, and now
>I can't render the TR/TD elements.  

If you remember, the TABLE elements didn't work because you were including
them as elements within your attribute value.  Similarly, any other element
you put in won't work because elements within attribute values are ignored.
 What you need to do is *serialise* the 'HTML' that you're producing, so
that you construct something that outputs:

  &lt;tr&gt;...&lt;/tr&gt;

and not:

  <tr>...</tr>

If you look at the code that I gave you for creating the A element, you'll
see that the trs are having templates applied to them in 'serialise' mode.
The point of the 'serialise' mode is to serialise the trs so that they get
output in the right way.

In the post that I sent, I gave you a template to do that:

<xsl:template match="*" mode="serialise">
  <xsl:text />&lt;<xsl:value-of select="name()" />
  <xsl:for-each select="@*">
    <xsl:text> </xsl:text>
    <xsl:value-of select="name()" />
    <xsl:text />="<xsl:value-of select="." />"<xsl:text />
  </xsl:for-each>
  <xsl:text>&gt;</xsl:text>
  <xsl:apply-templates mode="serialise" />
  <xsl:text />&lt;/<xsl:value-of select="name()" />&gt;<xsl:text />
</xsl:template>

If you put that in the stylesheet, then it will create serialised copies of
the tr and td elements in your source as they stand.  If you want to do
something special with trs, like add the VALIGN attribute, then you should
*also* have a special template that produces that:

<xsl:template match="tr" mode="serialise">
  <!-- beginning start tag here -->
  <xsl:text />&lt;<xsl:value-of select="name()" />
  <!-- adding VALIGN attribute here -->
  <xsl:text> VALIGN="center"</xsl:text>
  <!-- adding other attributes here -->
  <xsl:for-each select="@*">
    <xsl:text> </xsl:text>
    <xsl:value-of select="name()" />
    <xsl:text />="<xsl:value-of select="." />"<xsl:text />
  </xsl:for-each>
  <xsl:text>&gt;</xsl:text>
  <!-- adding serialised content here -->
  <xsl:apply-templates mode="serialise" />
  <!-- putting in end tag here -->
  <xsl:text />&lt;/<xsl:value-of select="name()" />&gt;<xsl:text />
</xsl:template>

Does that make more sense?

Cheers,

Jeni

Jeni Tennison
http://www.jenitennison.com/


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.