Re: [xsl] modify output document elements

Subject: Re: [xsl] modify output document elements
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 4 Mar 2020 18:01:05 -0000
On Wed, Mar 04, 2020 at 05:49:09PM -0000, Kammering, Raimund raimund.kammering@xxxxxxx scripsit:
> I have a stylesheet which creates a HTML output document dynamically based on the incoming XML file. 
[snip]
> 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?!

Stick the first pass -- your existing HTML document -- in a variable.
Then run that variable through apply-templates with a distinct mode set
on the templates to make the change you want.  Remember to set up an
identity template (XSLT 2) or mode definition (XSLT 3) for that mode.

This really is pretty simple and efficient, even if it seems weird at
first. And it has the advantage of keeping the two different sets of
rules -- create the HTML table, set details_table -- distinct in the
code.

-- Graydon

Current Thread