xsl-list
[Top] [All Lists]

Re: [xsl] modify output document elements

2020-03-04 12:01:11
On Wed, Mar 04, 2020 at 05:49:09PM -0000, Kammering, Raimund 
raimund(_dot_)kammering(_at_)desy(_dot_)de 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
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>