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

Re: modify output document elements

Subject: Re: modify output document elements
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 4 Mar 2020 18:01:15 -0000
Re:  modify output document elements
You can put a constructed sub-tree in a variable:

<xsl:variable name="t">
  <table>
    ...
  </table>
</xsl:variable>

and then do further transformations on the content of this variable

<xsl:apply-templates select="$t" mode="post-process"/>

If you're still using the old XSLT 1.0 version, there are restrictions on
using variables this way, which (with most processors) you can get around with
an extension function:

<xsl:apply-templates select="exsl:node-set($t)" mode="post-process"/>

Michael Kay
Saxonica

> On 4 Mar 2020, at 17:49, Kammering, Raimund raimund.kammering@xxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hello,
>
> I have a stylesheet which creates a HTML output document dynamically based
on the incoming XML file. I use some for-each loop to get the processing done
in the right order. My layout causes the stylesheet to look like this:
>
>  <xsl:template name="details_table">
>    <table border="0" cellspacing="0">
>      <tr>
>        <td width="64px">
>          <a href="#" onclick="toggle('{$details_table}')" title="show/hide
details">
>            <img src="show_hide.png"/>
>          </a>
>        </td>
>        <td>
>          Details
>        </td>
>      </tr>
>      <table id="{$details_table}" cellspacing="3" style="display: block">
>        <tr>
>          <td width="64px">
>            <img border="0" src="{$imagedir}/null.gif"/>
>          </td>
>          <th align="left">Start</th>
>          <th align="left">End</th>
>          <th align="left">Duration [h]</th>
>          <th align="left">Type</th>
>          <th align="left">Category</th>
>          <th align="left">Comment</th>
>        </tr>
>
>        <xsl:for-each
select="entry[severity='STATISTICS']/statistics_category">
>          ...
>          <xsl:choose>
>            <xsl:when test=".='Down'">
>              <td width="150" valign="top">
>                <xsl:choose>
>                  <xsl:when test="../Down='not_set'">
>                     <font color="red">not_set</font>
>                  </xsl:when>
>                  <xsl:otherwise>
>                     <xsl:value-of select="../Down"/>
>                  </xsl:otherwise>
>                </xsl:choose>
>              </td>
>            </xsl:when>
>            ...
>        </xsl:for-each>
>      </table>
>    </table>
>  </xsl:template>
>
> Now I would like to modify the style of the details_table depending on the
outcome of the test within the for-each loop. Since the table element has
already been created, I do not know how one could do this without changing the
overall logic. Is there a way to access the elements of the created HTML DOM
tree from within the stylesheet? Or am I hunting in the wrong direction?!
>
> Any ideas/help welcome - greetings,
> Raimund Kammering

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.