This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Rendering an HTML table twice


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:

  <tr>...</tr>

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]